I have an Arduino hanging / dev / ttyUSB 1 communicating in 115kbaud. The instructions below are great for the next method call where Pharo hangs. Arduino responds to the "99" command by sending one $ 1 character back to the computer. If I pull out the cable, the program will continue, and s will contain the character $ 1, as it should, but until I pull out the cable. Therefore, it seems to me that next 'does not return after it reads only one byte (well, of course, there is nothing that says that it should return after reading one byte). How can I read one byte from a stream in Pharo? Or how to open a stream of read / write bytes? I did not find anything in the source classes that seem to do this. I tried setting the stream to ascii, to binary, to text, and it does not change the behavior.
s := FileStream oldFileNamed: '/dev/ttyUSB1'.
s readWrite.
s nextPutAll: '99'. "'99' is successfully received by Arduino"
s next. "hangs here"
s close.
Thanks for your help.
source
share