Example serial code

0 views
Skip to first unread message

Andy Hunt

unread,
May 11, 1999, 3:00:00 AM5/11/99
to
Hi,

I'm on the point of having to write some code to control a motorised
microscope stage via a serial controller. Has anyone got any code
examples on how to interact with the serial port, I need more than just
the snippets in the manual.

Thanks

Andy
Andy Hunt
Software Engineer
Foster Findlay Associates

Scott Redman

unread,
May 11, 1999, 3:00:00 AM5/11/99
to

# excuse me if I make a mistake, this is off the
# top of my head....

# substitute your serial port for com1:, such
# as /dev/ttya on Solaris

set serialPort com1:

proc readData {port} {

if [eof $port] {
close $port
} else {
gets $port
}
}

set port [open $serialPort RDWR]
fconfigure $port -blocking 0 -buffering none -mode 9600,o,8,1

fileevent $port readable [list readData $port]
puts $port "start"

Andy Hunt

unread,
May 12, 1999, 3:00:00 AM5/12/99
to
In article <373872A4...@scriptics.com>, Scott Redman
<red...@scriptics.com> writes

>
># excuse me if I make a mistake, this is off the
># top of my head....
>
># substitute your serial port for com1:, such
># as /dev/ttya on Solaris
>
>set serialPort com1:
>
>proc readData {port} {
>
> if [eof $port] {
> close $port
> } else {
> gets $port
> }
>}
>
>set port [open $serialPort RDWR]
>fconfigure $port -blocking 0 -buffering none -mode 9600,o,8,1
>
>fileevent $port readable [list readData $port]
>puts $port "start"
>
>

Thanks Scott, of the top of your head is better than off the top of
mine, all I've got is a bald patch that I scratched there :)!


There seems to be a dearth of material on how to do this (at least I've
not found any yet) and quite a few people asking about it. If^H^H When I
get this working I may post some of the relevant bits, assuming I can
take the time off from scratching!

Reply all
Reply to author
Forward
0 new messages