View Full Version : serial command issue
ghy
October 8th, 2006, 02:40 PM
So.. what I'm trying to do is send serial commands to a DCE device, but what's throwing me is the fact that carriage returns need to follow all commands. I've searched the forums, and tried adding terminators like string.char(13) to no avail.
The only information I have on this device is the following:
-9600 baud
-no parity
-8 bits
-1 stop bit
-port type is DCE
-carriage returns must be set following all commands
-commands aren't echoed, so the terminal device should be set to "local echo on" if local echoing is required. I don't need echoing, but it might be of some importance.
The serial commands are:
format_button=FILM
format_button=STOP
format_button=?
I'm attaching my .lua, which will probably reveal what a novice I really am. Any help would be VERY much appreciated :)
toml0006
October 8th, 2006, 06:14 PM
Instead of:
string.char(13)
try
serial.hextobyte ('0D')
the string class in lua is quite problematic.
ghy
October 8th, 2006, 06:47 PM
Thanks Tom. That's good to know. Alas, my problem still persists and I can't get my serial commands through. I'm guessing the CR wasn't the issue...
Any ideas? Do DCE ports require something different? I've tried using a null cable as well, with equally poor results.
Rob H
October 8th, 2006, 11:10 PM
Have you've tried mailing dan@stimaging.com for more information on the protocol (assuming this is an ST100 microfilm scanner)?
ghy
October 14th, 2006, 04:39 PM
Rob, it isn't the ST100 microfilm scanner. Thanks for the suggestion though.
If it specifies that the port type is DCE, is that significant? (i.e. should I be doing something else?)
Rob H
October 14th, 2006, 11:35 PM
I'm an idiot, sorry. Should have noticed that you've made the understandable mistake that you need to use StopBits = 0 to get 1 stop bit. That pretty much catches everyone out!
ghy
October 15th, 2006, 11:49 AM
I caught myself on that mistake as well :)
But unfortunately, it doesn't seem to help my situation. Ergh.
Any other possibilities?
dsmes
October 15th, 2006, 01:04 PM
you need to use StopBits = 0 to get 1 stop bit. That's strange. I'm experimenting with a serial device and set StopBits = 1 and it does just that.
Serial: WeederAnalog : Opened Device: WeederAnalog Port: 3 Settings: 9600 N 0 8 1
The above is from the Lua interactive console when Girder starts. And in Variable Display, the variable StopBits is also 1. I'm at v4.0.8.1. Did this change (get fixed) recently?
Rob H
October 16th, 2006, 07:25 AM
That just reports the value of the serial device's StopBits setting. That will translate to 1.5 stopbits on the actual serial port.
Rob H
October 16th, 2006, 07:26 AM
ghy: What is the device you are actually trying to control?
Have you tried talking to it using Hyperterm?
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.