You are not logged in.

#1 2008-03-18 20:09:34

F1y3r
Member
Registered: 2007-09-28
Posts: 61

script to monitor rs-232

Hi!
I would like to build headless mp3 player/server and I would like to control it locally. I found this scheme: esquema.jpg
Basically it's CD DSR CTS RI pins connected to the DTR.
Here's part of the script I'm looking for:

#!/usr/bin/expect
global Port
global Serial
set Serial "/dev/ttyUSB2"
set last "off"

proc cleanup {} {
global Version
global Port
   close $Port
   exit
}
trap cleanup {SIGINT SIGHUP SIGQUIT SIGUSR1 SIGTERM}

proc monitor {} {
global Port
global last
   set DCD [lindex [fconfigure $Port -ttystatus] 7]
   set DCDstate "off"
   if {$DCD == 1} {
      set DCDstate "on"
   }
   if {$DCDstate != $last} {
      catch {exec /usr/local/bin/someprogram &}
      set last $DCDstate
   }
   after 5000 monitor
}

monitor
while {1} {
   after 1000
}

When I try to execute I get this:

 [flyer@athlon ~]$ ./serial.exp 
can't read "Port": no such variable
    while executing
"fconfigure $Port -ttystatus"
    (procedure "monitor" line 4)
    invoked from within
"monitor"
    (file "./serial.exp" line 30)

What's wrong with the script? Could anyone fix it?

Thanks in advance

Offline

Board footer

Powered by FluxBB