Serial ports, control characters, sgitcl 
Author Message
 Serial ports, control characters, sgitcl

Several months ago I wrote a very short Tcl script that would send a short
string, "^Xr^Y" (where ^X indicates <Control+X>, etc.) out a serial port
on one SGI Challenge, to shut down another SGI Challenge.

However, on checking up on it more recently, we discovered that though the
script doesn't produce any errors, it no longer seems to have the desired
effect.

What is strangest about this is if I enter the tclsh shell, and
cut-and-paste the lines from the script one-by-one to the command line, it
works.

The version of sgitcl we're using is based on Tcl 7.4.  This includes some
or all of TclX, but I'd like to avoid using TclX commands to keep this
thing as portable as possible, in case it is decided that we should use a
different Tcl.

The script follows:

#!/usr/sgitcl/bin/sgitcl

set port /dev/ttyd3
set portid [open $port w]
set ctl_x "\30"
set ctl_y "\31"

puts -nonewline $portid "${ctl_x}r${ctl_y}"
close $portid

#==End Script==

Thanks for any help,

Bob Schmertz



Fri, 07 Sep 2001 03:00:00 GMT  
 Serial ports, control characters, sgitcl
Can anyone tell my why this now works?

I seem to have solved my problem by a bizarre hack, that I really stumbled
on by accident, and for which I have no explanation.  If I put any one of
the following lines somewhere after the puts command that sends the
control-character string out the port, I get the effect I want.

env
exec env
catch {env}

So it works, but I'd still like to know why.  It would be much better to
have a command that explicitly does whatever crucial thing these commands
are doing, rather than have it be an unexplained side effect of an
extraneous command.

P.S. I tried putting "flush $portid" after the puts command, but that had
no effect either way.

Quote:

>Several months ago I wrote a very short Tcl script that would send a short
>string, "^Xr^Y" (where ^X indicates <Control+X>, etc.) out a serial port
>on one SGI Challenge, to shut down another SGI Challenge.

>However, on checking up on it more recently, we discovered that though the
>script doesn't produce any errors, it no longer seems to have the desired
>effect.

>What is strangest about this is if I enter the tclsh shell, and
>cut-and-paste the lines from the script one-by-one to the command line, it
>works.

>The version of sgitcl we're using is based on Tcl 7.4.  This includes some
>or all of TclX, but I'd like to avoid using TclX commands to keep this
>thing as portable as possible, in case it is decided that we should use a
>different Tcl.

>The script follows:

>#!/usr/sgitcl/bin/sgitcl

>set port /dev/ttyd3
>set portid [open $port w]
>set ctl_x "\30"
>set ctl_y "\31"

>puts -nonewline $portid "${ctl_x}r${ctl_y}"
>close $portid

>#==End Script==

>Thanks for any help,

>Bob Schmertz

Cheers,
Bob Schmertz


Sun, 09 Sep 2001 03:00:00 GMT  
 Serial ports, control characters, sgitcl
A number of problems.  You're not initializing the port so you can't
be assured how your bits are going to be interpreted.  More likely,
you're not checking to make sure the 2nd SGI is reading while you're
writing.  This last point is a little subtle and depends on whether
your system buffers I/O while (or after) waiting for DTR to be raised
on a serial port.  (This is why so many client-server protocols have
the server produce a prompt before the client does anything.)  And so
on.

Don

Quote:

} Can anyone tell my why this now works?
}
} I seem to have solved my problem by a bizarre hack, that I really stumbled
} on by accident, and for which I have no explanation.  If I put any one of
} the following lines somewhere after the puts command that sends the
} control-character string out the port, I get the effect I want.
}
} env
} exec env
} catch {env}
}
} So it works, but I'd still like to know why.  It would be much better to
} have a command that explicitly does whatever crucial thing these commands
} are doing, rather than have it be an unexplained side effect of an
} extraneous command.
}
} P.S. I tried putting "flush $portid" after the puts command, but that had
} no effect either way.
}

}
} >Several months ago I wrote a very short Tcl script that would send a short
} >string, "^Xr^Y" (where ^X indicates <Control+X>, etc.) out a serial port
} >on one SGI Challenge, to shut down another SGI Challenge.
} >
} >However, on checking up on it more recently, we discovered that though the
} >script doesn't produce any errors, it no longer seems to have the desired
} >effect.
} >
} >What is strangest about this is if I enter the tclsh shell, and
} >cut-and-paste the lines from the script one-by-one to the command line, it
} >works.
} >
} >The version of sgitcl we're using is based on Tcl 7.4.  This includes some
} >or all of TclX, but I'd like to avoid using TclX commands to keep this
} >thing as portable as possible, in case it is decided that we should use a
} >different Tcl.
} >
} >The script follows:
} >
} >#!/usr/sgitcl/bin/sgitcl
} >
} >set port /dev/ttyd3
} >set portid [open $port w]
} >set ctl_x "\30"
} >set ctl_y "\31"
} >
} >puts -nonewline $portid "${ctl_x}r${ctl_y}"
} >close $portid
} >
} >#==End Script==
} >
} >Thanks for any help,
} >
} >Bob Schmertz
} >
}
} Cheers,
} Bob Schmertz
}



Mon, 10 Sep 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Serial Error 0x4002 (Error 16386, character was lost by overwrite / serial port overrun error)

2. Any free library to control parallel port and serial port

3. Win32/Python serial port event character problem

4. Serial Com port looses characters.

5. Win32/Python serial port event character problem

6. Win32all serial port event character problem.

7. VW2.5 Serial Port control

8. serial port control

9. Controlling Serial Ports

10. Serial Port Control via VB DLL

11. Trouble with using HP34401a.lib to control HP34401a multimeter through serial port

12. Control Serial Port

 

 
Powered by phpBB® Forum Software