User Tools

Site Tools


sending_20a_20serial_20break

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sending_20a_20serial_20break [2018/03/31 13:19]
127.0.0.1 external edit
sending_20a_20serial_20break [2018/04/17 18:38] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //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:\\ \\  //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:\\ \\ 
 +<code bb4w>
         SYS "​SetCommBreak",​ @hfile%(com1%)         SYS "​SetCommBreak",​ @hfile%(com1%)
         WAIT 50         WAIT 50
         SYS "​ClearCommBreak",​ @hfile%(com1%)         SYS "​ClearCommBreak",​ @hfile%(com1%)
 +</​code>​
 Here **com1%** is the value returned from [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwinf.html#​openport|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:\\ \\  Here **com1%** is the value returned from [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwinf.html#​openport|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:\\ \\ 
 +<code bb4w>
         com1% = OPENUP("​COM1:​9600,​n,​8,​1"​)         com1% = OPENUP("​COM1:​9600,​n,​8,​1"​)
         IF com1% = 0 ERROR 100, "​Couldn'​t open serial port COM1"         IF com1% = 0 ERROR 100, "​Couldn'​t open serial port COM1"
Line 14: Line 17:
  
         CLOSE #com1%         CLOSE #com1%
 +</​code>​
sending_20a_20serial_20break.txt ยท Last modified: 2018/04/17 18:38 by tbest3112