-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring hardware_check.rs back into service #107
Bring hardware_check.rs back into service #107
Conversation
Sirhcel - I see that our results are quite similar ... I've been running/testing example app 'hardware_check.rs' on Windows, and have the following update:
I'm currently awaiting delivery of a loop-back connector so I can execute the application in single port in true loop-back mode. I expect to have additional crate related test details to discuss when we meet. Once it's decided which testing improvements are appropriate (and how to package them), I'll plan to provide a push request with the associated new code or code updates. |
Thank you for your extensive reply @jerrywrice! I'm happy that we are seeing similar issues and thank you for digging deeper into it! I will digest your response the next days and likely give multiple answers. Just as a starter:
That's an interesting point. I will have a look with an ocscilloscope at the actual baud rate on the wire. I was running my tests on Windows 10 on real hardware (no VM) with two SiLabs CP2102N USB serial adapters back to back and my Windows survived this tests without showing any issues. Could you please share a link to this piece of documentation from Microsoft? Which serial hardware are you using? I'm wondering whether this might be caused by a driver when 2 Mbaud are apparently out of spec on Windows.
I agree with you in general. I have not checked the implementations but |
Christian - as you know my input regarding the maximum baud rate with Windows serial ports is more nuanced. Microsoft doesn't clearly document that there is a 'maximum' (enforced) baud rate setting, rather they document their standard baud rates. I assume this gives their technical support team an 'out' if a customer files a technical incident report and encounters a failure when using a higher 'non standard' rate, such as 2_000_000. The relevant MS link is https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-dcb?redirectedfrom=MSDN As you know, Windows accepts user specified numeric baud rate values other than those defined in this document page (such as 2_000_000). My understanding is that the Windows OS and I/O system is not (internally) designed and coded as efficiently as Linux, and therefore will not achieve Linux like upper serial transfer speeds. That is my theory - but I don't have the means nor time to verify this. My development laptop runs Windows x64 Professional 10.0.19045 - with an Intel Xeon W-11955M 2.6 Ghz (2611 Mhz) 8 core CPU (16 logical processors) with 64 Gb of RAM. I'm using (2) null modem connected FTDI USB serial cables with the FTDI driver version 2.12.36.4. At this time my null-modem is in-fact a cable which is about 10 feet long (not ideal!). I'll replace this with a simple connector style null-modem when I get access to one. I can now transfer serial data successfully (in Windows) up to 550 KBaud, but when I attempt 560 KBaud the recv_exact() errors and panics. I haven't looked at this any deeper - but will likely do so after we discuss and decide what additional (example) test Note that it should be possible (using threads) to generate a test that iterates and determines a maximum usable baud rate on a given test computer and cable setup. Whether this is the most important thing to deal with at this time is another question ... |
It's not possible for this library to determine the maximum possible baudrate for all windows serial devices, as this value depends on the driver implementation. So I don't think it's correct for us to enforce any limitation on the baudrate value. If the driver fails to indicate when we try to set an unsupported baudrate, that is a bug in the driver -- not serialport-rs. C#'s serialport implementation indicates much the same: https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.baudrate?view=dotnet-plat-ext-7.0 Moreover, the water becomes quite muddy when considering USB serial devices. The baudrate 'on the line' and the baudrate in the driver are not comparable, as the data is being sent as USB packets, and is confounded by pesky details like the USB polling rate, packet size, if the driver is sending partial packets, the size of the USB buffer on both ends, etc. |
Agreed. Nevertheless, I suggest that crate supplied example applications avoid utilizing exceptionally high baud rates which are prone to fail with typical hardware (especially on Windows). It creates confusion with users trying the crate for the first time if one of the examples fails 'out of the box'. They'll likely submit an unnecessary PR, or else avoid the crate altogether. Cheers |
Great, than we are gaining the same understanding of baud rate limiting.
We should go slow and sort things out first. I bear with you, that we should not ship defaults/examples which commonly fail on a certain platform. I hooked up the logic analyzer last night and can report, that on my Windows machine, the transmission with 2 Mbaud actually happened with 2 Mbaud and went perfectly fine. And if I'm reading it correctly, this works with a 50:50 chance on your systems. I would call it early to label this baud rate failing on typical hardware - especially with issues in the queue like the read timeouts which reportedly are causing more trouble. What I would love to see in the long term would be a set of test applications for quantifying the properties/quality of a serial transmission channel. Just to type while thinking: With ramping up speeds, testing a serious amount of transmission data, checking flow control, ... |
I will continue here for having this discussion in one place, but #106 looks like the better one as there are several points which are not directly related with this PR. With this PR I'm aiming at getting Maybe creating a work-in-progress PR for your changes @jerrywrice might help the discussion.
This sounds reasonable. Basic communication testing should not involve flow control at all and enabling software flow control lays a potential trap for young players.
Agreed and also done in this PR. I also included not converting the received data to UTF-8 to avoid panicking without printing the data actually received in case of bad UTF-8.
Agreed. I would leave this to your or further PRs. Once we are opening this field, we should also think about how to test communication between different platforms as this might point out faulty flow control.
This is surely a limitation of
Looks to me like we are getting into the realm of advanced multi process/multi platform_ testing again. I'm thinking about this since a while and having a remotely controllable communication pair could help out here. Maybe pyserial's/a RFC 2271 proxy/server/... could perform this task and we don't have to write our own.
|
Per your feedback, new comments related to additional example testing will be on #106 |
There was a lot of general discussion going on here recently. The update to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is great to improve on the tests, thank you!
I did not manage to run
hardware_check.rs
on Linux and macOS because the tests failed due to missing or wrong received data. This happened due to reading with a timeout of zero and not clearing already received data from previous test cases. This is one small step for #106.This PR addresses these two by:
It also includes the following additions:
Successfully ran the tests on Linux, macOS, and Windows.