Keep It Simple, Stupid | |
PerlMonks |
Re^3: r/w attached infrared head on /dev/ttyUSB0by haukex (Archbishop) |
on May 25, 2019 at 23:59 UTC ( [id://11100541]=note: print w/replies, xml ) | Need Help?? |
Unfortunately, I wasn't able to reproduce anything like the issue you're having on my system, at least using a fake PTY. I ran both a shell script with the commands from the root node and this Perl script under strace -s256 -fe trace=read,write,ioctl, and in both cases the basic outline seemed to be the same, in particular, this bit was the same for both commands:
... and I was able to send all of the response lines from your root node to the Perl script and it received it just fine. This seems to indicate to me that the device you are talking to is behaving differently for the shell commands and the Perl script, for which I think the most likely explanation is either differing configuration or differences in what gets sent to the device, which is why I was wondering what the difference between the two is, but I don't see it yet. I did have some issues where my stty complained about not knowing the modes crtscts onlcr echoctl echoke, but I'm not sure that has to do with the issue. Do you need all of those switches, or would the simpler form I showed in my node, cs7 parenb -parodd raw -echo, be enough? What OS are you on exactly? Do you happen to know what kernel driver this device is using? You could try running the same strace I showed above to see if there are significant differences between the shell commands and the Perl script on your system. A couple of other ideas to check on: I did notice you added raw to the stty modes, I'm not sure if that makes a difference on your system. Also, I am wondering why you are getting the output /?! 000, since that's actually what your code is sending, i.e. maybe something went wrong in disabling echo. Plus, in the root node you're opening the port with cat before you do the stty, have you tried the cat afterwards to see if that makes a difference? Are you sure the code you've posted here is exactly what you are running? (In your root node, I'm not sure what the "Finish!" means.) Are you using strict and warnings? Lastly, are you sure that no other commands are mucking with the port while your Perl script is running, e.g. did you remember to kill all the backgrounded cat & commands?
In Section
Seekers of Perl Wisdom
|
|