Yeah, that's probably fine - but it's still something I'd look at for workarounds... that whole "connect then fail to interact" thing sounds familiar...  it's waiting for something that never comes, or the return is swallowed by the USB serial chip...


On Mon, 20 Aug 2018 at 10:47, cory seligman <coryms.luv@gmail.com> wrote:
Yes, I am using a USB serial dongle. It's a known reasonably good quality brand that otherwise works fine interactively.





On Mon, Aug 20, 2018 at 10:33 AM, Paul van den Bergen <paul.vandenbergen@gmail.com> wrote:
are you using a USB to Serial dongle? for some time now they've been a standardised SoC that apparently handles breaks poorly... so if the system is expecting a break...

(found this out for Unify PABX and Cisco serial - in the latter case, dropping the speed to 2400 and holding down space bar for 15 seconds was enough to fake a break - go figure... weird )


On Mon, 20 Aug 2018 at 10:29, cory seligman via luv-main <luv-main@luv.asn.au> wrote:
Hi All,

I'm having some trouble making expect work.

I need it to talk to some vintage equipment over usb serial, and I think I'm getting hung up on opening the port.

When the script runs, it just connects to the device and sits there. I can drive it interactively, but it doesn't attempt to automate anything.

Any ideas? Thanks.

My expect script looks like this:

#!/usr/bin/expect -f

# device
set modem /dev/ttyUSB0

# keep it open
exec sh -c "sleep 3 < $modem" &

# serial port parameters
exec stty -F $modem 2400 raw -clocal -echo -istrip -hup

# connect
send_user "connecting to $modem, exit with ~,\n"
spawn -open [open $modem w+]
interact {
    ~, exit
    ~~ {send "\034"}
}

set force_conservative 1 ;# set to 1 to force conservative mode even if
              ;# script wasn't run conservatively originally
if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
        sleep .1
        exp_send -s -- $arg
    }
}

set timeout -1
match_max 100000
send -- "\r"
send -- "\r"
expect  ">"
send -- "p 7d91\r"
expect  ">"
send -- "p b2ff\r"
expect  ">"
send -- "h\r"
expect  ">"
send -- "td\r"
expect "td\r
  18 215  12  24  33\r
>"
send -- "gd 215\r"
expect eof



_______________________________________________
luv-main mailing list
luv-main@luv.asn.au
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main


--
Dr Paul van den Bergen




--
Dr Paul van den Bergen