Posted to tcl by grummund at Thu Jun 01 19:32:23 GMT 2017view pretty
#!/usr/bin/expect -f log_file -noappend modbustest.log set device /dev/ttyUSB0 spawn -open [open $device r+] stty 9600 cs8 parenb -cstopb raw < $device fconfigure $spawn_id -encoding binary -translation binary # fconfigure stdin -encoding binary -translation binary # fconfigure stdout -encoding binary -translation binary send "\xE0\x10\x4E\x74\x00\x02\x04\x42\x78\x00\x00\x4F\x85" expect "\xE0\x10\x4E\x74\x00\x02\x01\x4B" after 1000 send "\xE0\x10\x4E\x72\x00\x02\x04\x44\x7A\x00\x00\x6E\xE7" expect "\xE0\x10\x4E\x72\x00\x02\xE1\x4A" after 1000 send "\xE0\x06\x00\x64\x00\x00\xDF\xA4" expect "\xE0\x06\x00\x64\x00\x00\xDF\xA4" after 1000 send "\xE0\x06\x00\x65\x00\x00\x8E\x64" expect "\xE0\x06\x00\x65\x00\x00\x8E\x64" after 1000 send "\xE0\x06\x00\x66\x00\x00\x7E\x64" expect "\xE0\x06\x00\x66\x00\x00\x7E\x64" after 1000 send "\xE0\x06\x00\xC8\x00\x05\xDF\x86" expect "\xE0\x06\x00\xC8\x00\x05\xDF\x86" exit