|
fgetl hangs reading serial port: msg#00015gnu.octave.bugs
On 12-Apr-2005, R. Bruce Madigan <bmadigan@xxxxxxxxx> wrote: | To: bug-octave@xxxxxxxxxxxxxxxxx | Cc: bmadigan | Subject: fgetl hangs reading serial port | -------- | Bug report for Octave 2.1.40 configured for i386-redhat-linux-gnu 2.1.40 is really quite old (that snapshot was made almost 2-1/2 years ago). The current recommended version is 2.1.69. | I cannot read data from a serial device from within octave. I establish | communication with the device using minicom and am able to send and | receive. I exit minicom (with minicom configured to do nothing to the | port when it exits) and run the following program: | | [fid,msg]=fopen("/dev/ttyS0","r+","native") | cmdstr=setstr([0x41,0x54,0x0d,0x00]) | fputs(fid,cmdstr) | sleep(1); | fgetl(fid) | fclose(fid) | | The program hangs at fgetl. That's probably because Octave uses blocking I/O by default. | I have used the procedure on two different | computers and talked to two different devices. (The example above is | talking to a modem, sending "AT" and expecting "OK"). I am sure the | command string (cmdstr) is reaching the serial device because I can see | a change of status on the serial device ( for example the send data and | reveive data lights on the modem blink). The following works for me with a recent version of Octave: octave:22> f = fopen ("/dev/ttySL0", "r+") f = { id = 3 name = /dev/ttySL0 mode = r+b arch = ieee_little_endian status = open } octave:23> fcntl (f, F_SETFL, O_NONBLOCK) ans = 0 octave:24> fputs (f, "AT\n") ans = 0 octave:25> fgetl (f) ans = AT octave:26> fgetl (f) ans = octave:27> fgetl (f) ans = OK octave:28> fgetl (f) ans = -1 octave:29> fputs (f, "AT\r") ans = -1 octave:30> fclear (f) octave:31> fputs (f, "AT\r") ans = 0 octave:32> fgetl (f) ans = AT octave:33> fgetl (f) ans = OK octave:34> fgetl (f) ans = -1 octave:35> fclose (f) ans = 0 jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html ------------------------------------------------------------- |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | fscanf performance >10x slower in 2.1.69 compared to 2.1.50 on Windows: 00015, John W. Eaton |
|---|---|
| Next by Date: | Re: fscanf performance > 10x slower in 2.1.69 compared to 2.1.50 on Windows: 00015, Comcast wlmsears |
| Previous by Thread: | fgetl hangs reading serial porti: 00015, R. Bruce Madigan |
| Next by Thread: | clear all and gnuplot (was Weird error with gnuplot: 'invalid command'): 00015, Alexander Klink |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |