simple_20terminal_20program
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
simple_20terminal_20program [2018/03/31 13:19] – external edit 127.0.0.1 | simple_20terminal_20program [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Colin McDonagh, April 2007//\\ \\ In my work, I often need to communicate with older pieces of equipment via **RS232** cables. Of course there are many such applications available, but it's quite easy in BBC BASIC. First we set up the com port we want to use, in this case com1.\\ | //by Colin McDonagh, April 2007//\\ \\ In my work, I often need to communicate with older pieces of equipment via **RS232** cables. Of course there are many such applications available, but it's quite easy in BBC BASIC. First we set up the com port we want to use, in this case com1.\\ | ||
+ | <code bb4w> | ||
REM a simple terminal program. | REM a simple terminal program. | ||
Port% = OPENUP "COM1: baud=9600 parity=N data=8 stop=1" | Port% = OPENUP "COM1: baud=9600 parity=N data=8 stop=1" | ||
Line 9: | Line 10: | ||
DIM commtimeouts{rit%, | DIM commtimeouts{rit%, | ||
SYS " | SYS " | ||
+ | </ | ||
If the com port is being used by another application, | If the com port is being used by another application, | ||
+ | <code bb4w> | ||
REM chars% | REM chars% | ||
REPEAT | REPEAT | ||
REM get the number of characters. | REM get the number of characters. | ||
chars% = EXT#Port% | chars% = EXT#Port% | ||
+ | </ | ||
**chars%** is the number characters waiting to be read. If there are no characters in the serial buffer, the keyboard is read with **INKEY**.\\ | **chars%** is the number characters waiting to be read. If there are no characters in the serial buffer, the keyboard is read with **INKEY**.\\ | ||
+ | <code bb4w> | ||
REM Number of characters waiting in the serial input buffer, for a read action. | REM Number of characters waiting in the serial input buffer, for a read action. | ||
IF chars%=0 THEN | IF chars%=0 THEN | ||
Line 22: | Line 27: | ||
k% = INKEY(0) | k% = INKEY(0) | ||
ENDIF | ENDIF | ||
+ | </ | ||
If **k% = -1** nothing was entered on the keyboard.\\ | If **k% = -1** nothing was entered on the keyboard.\\ | ||
- | ===== | + | <code bb4w> |
- | \\ | + | |
REM If a character has been entered via keyboard, send it to serial output buffer | REM If a character has been entered via keyboard, send it to serial output buffer | ||
IF k%>-1 THEN BPUT# | IF k%>-1 THEN BPUT# | ||
UNTIL FALSE | UNTIL FALSE | ||
END | END | ||
+ | </ | ||
Otherwise the number of characters, is passed as a parameter to **PROCSendToVDU**\\ | Otherwise the number of characters, is passed as a parameter to **PROCSendToVDU**\\ | ||
+ | <code bb4w> | ||
DEF PROCSendToVDU(chrs%) | DEF PROCSendToVDU(chrs%) | ||
LOCAL index%, Data% | LOCAL index%, Data% | ||
Line 40: | Line 47: | ||
ENDIF | ENDIF | ||
ENDPROC | ENDPROC | ||
+ | </ |
simple_20terminal_20program.1522502382.txt.gz · Last modified: 2024/01/05 00:16 (external edit)