User Tools

Site Tools


sending_20a_20serial_20break

Sending a serial break

by Richard Russell, July 2007

Occasionally you may wish to send a break condition on a serial port output line. For example this may be needed to 'wake up' a remote device such as a modem. You can easily do that using the following code:

        SYS "SetCommBreak", @hfile%(com1%)
        WAIT 50
        SYS "ClearCommBreak", @hfile%(com1%)

Here com1% is the value returned from OPENUP when the serial port was opened. In this example the break condition is maintained for about 0.5 seconds (50 centiseconds).

For completeness here is a self-contained program which opens the port, sends the break, and then closes the port:

        com1% = OPENUP("COM1:9600,n,8,1")
        IF com1% = 0 ERROR 100, "Couldn't open serial port COM1"
 
        SYS "SetCommBreak", @hfile%(com1%)
        WAIT 50
        SYS "ClearCommBreak", @hfile%(com1%)
 
        CLOSE #com1%
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
sending_20a_20serial_20break.txt · Last modified: 2024/01/05 00:21 by 127.0.0.1