This pull-request follows the discussion on #10 and suggests an implementation that is fully backward-compatible.
The initial problem, as stated in the discussion, is that the code was recently modified to allow for non-standard baud-rates on OSX (see #7). While those changes indeed do what they are supposed to, they rely on a non-standard/non-portable IOCTL that only works on real serial devices, but fails on everything else.
Since this non-standard IOCTL is only ever needed when we want to set a non-standard baud-rate, the suggested changes here first test if the desired baud-rate is a standard one (that list is static anyway) and then decide on a strategy. If the baud-rate is standard, we use the standard IOCTL. If it isn't, we use the non-standard IOCTL as implemented in #7.
I also added unit-tests for the new introduced function, even though its implementation is particularly trivial.
Thank you very much! Looks good, except for posterity could you please capture some/all of the discussion that you put in the PR into the commit description?
This pull-request follows the discussion on #10 and suggests an implementation that is fully backward-compatible.
The initial problem, as stated in the discussion, is that the code was recently modified to allow for non-standard baud-rates on OSX (see #7). While those changes indeed do what they are supposed to, they rely on a non-standard/non-portable IOCTL that only works on real serial devices, but fails on everything else.
Since this non-standard IOCTL is only ever needed when we want to set a non-standard baud-rate, the suggested changes here first test if the desired baud-rate is a standard one (that list is static anyway) and then decide on a strategy. If the baud-rate is standard, we use the standard IOCTL. If it isn't, we use the non-standard IOCTL as implemented in #7.
I also added unit-tests for the new introduced function, even though its implementation is particularly trivial.
Let me know what you think @jacobsa !