Bash and serial port
Hello there !
I try to use bash for send datas to an external computer. I have try this : Code:
#!/bin/bash As soon the external computer has get the datas and made his job he send a single ">" (no crlf, no eol, etc...) to the serial port. I think I can read the serial port and as soon as I get a ">" send the next line. So I try Code:
#!/bin/bash And the "while read... done < $port" look to be an endless loop. How could I change the code to do the job ? Thanks for the help. Philippe |
IMHO bash is not the best language for accessing serial port data and can be unreliable. Here is a quick python script. Change serial port parameters as necessary. It will wait for a single character response and then continue sending data. The serial module is not installed by default.
Code:
#!/usr/bin/python3 |
@OP I guess you should open the device only once, e.g.
Code:
#!/bin/bash |
I heartily agree with @michaelk: "use a real language." Also, avail yourself fully of the many packages that are available for use in those languages.
Quote:
While "bash" has very rudimentary scripting capability, it never was intended to be used for "real work." (Only the Korn shell, "ksh," had a serious built-in language.) The elegantly-simple "shebang" mechanism means that it doesn't need to. |
All times are GMT -5. The time now is 12:40 AM. |