Hi!
I have a long experience in programming under Visual Basic, PHP, Javascript and microcontroller, but I'm absolutly newbie in bash script, so thanks in advance for your help !
Anyway, I've a home server with Nas4Free (based on FreeBSD 9.2-RELEASE-p3 (kern.osreldate: 902001) ) and I'm trying to write a simple bash script that reads datas from serial port and write those datas to a text file. I've succeed in writing in a text file, but I've lot of problems with serial port !
This is the configuration of the serial port : speed is 1200, 1 start bit "0", 7 bits per character, 1 parity even and 1 stop bit
This is the configuration I've tested for ttyu0 :
Then checked with
returns
To be sure that datas are send, I've put a spy module on the link cable to watch datas ; all is ok.
First, I've tried to send datas from FreeNas to Hyperterminal in Windows with
and everything is ok.
Then, I've tried to read datas on FreeNas from Hyperterminal with a small bash script :
But the script run without doing anything, and stop after about 5 mn (maybe the watchdog ...)
After having read lots of forum, man page and tutorial, nothing really happen, except once when I wrote
before running the previous script. I was happy as I thought that I've found the solution, but I restarted the computer and test this solution one more time, then it didn't work any more ...
I've tested
and after a few seconds it returns link down
I don't know what to do now ! It's so easy on windows or microcontroller ! Just initialize the serial port, open it then read the buffer ...
I've tested so many things that I don't know in wich way I have to go now ...
I have a long experience in programming under Visual Basic, PHP, Javascript and microcontroller, but I'm absolutly newbie in bash script, so thanks in advance for your help !
Anyway, I've a home server with Nas4Free (based on FreeBSD 9.2-RELEASE-p3 (kern.osreldate: 902001) ) and I'm trying to write a simple bash script that reads datas from serial port and write those datas to a text file. I've succeed in writing in a text file, but I've lot of problems with serial port !
This is the configuration of the serial port : speed is 1200, 1 start bit "0", 7 bits per character, 1 parity even and 1 stop bit
This is the configuration I've tested for ttyu0 :
Code:
stty -f /dev/ttyu0.init 1200 cs7 -parodd parenb -cstopb -icanon -iexten -ixon -ixoff -crtscts cread clocal echo -echoe echok -echoctl
Code:
stty -a -f /dev/ttyu0.init
Code:
speed 1200 baud; 0 rows; 0 columns;
lflags: -icanon isig -iexten echo -echoe echok echoke -echonl -echoctl
-echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr -ixon -ixoff ixany imaxbel -ignbrk
brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs7 parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
First, I've tried to send datas from FreeNas to Hyperterminal in Windows with
Code:
echo 123 > /dev/ttyu0
Then, I've tried to read datas on FreeNas from Hyperterminal with a small bash script :
Code:
#!/bin/sh
read ligne < /dev/ttyu0
/bin/echo $ligne
After having read lots of forum, man page and tutorial, nothing really happen, except once when I wrote
Code:
kill -HUP 1
I've tested
Code:
cu -l /dev/ttyu0
I don't know what to do now ! It's so easy on windows or microcontroller ! Just initialize the serial port, open it then read the buffer ...
I've tested so many things that I don't know in wich way I have to go now ...