User Tools

Site Tools


notes_20for_20risc_20os_20users

Differences

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

Link to this comparison view

notes_20for_20risc_20os_20users [2018/03/31 13:19]
127.0.0.1 external edit
notes_20for_20risc_20os_20users [2018/04/17 17:48] (current)
tbest3112 Added syntax highlighting
Line 24: Line 24:
 ==== Serial device ==== ==== Serial device ====
  On windows the serial device can be opened for input //and// output on the same channel, whereas on RISC OS the serial device has to be opened seperately for input and output.\\ ​  On windows the serial device can be opened for input //and// output on the same channel, whereas on RISC OS the serial device has to be opened seperately for input and output.\\ ​
 +<code bb4w>
     REM Open serial device on Windows     REM Open serial device on Windows
     ser%=OPENUP"​COM1:​ 9600,​8,​N,​1"​     ser%=OPENUP"​COM1:​ 9600,​8,​N,​1"​
Line 30: Line 31:
     serin%=OPENIN("​Serial:"​)     serin%=OPENIN("​Serial:"​)
     serout%=OPENOUT("​Serial:"​)     serout%=OPENOUT("​Serial:"​)
 +</​code>​
 \\  If you are converting code and are tempted to use:​\\ ​ \\  If you are converting code and are tempted to use:​\\ ​
 +<code bb4w>
     serin%=OPENUP"​COM1:​ 9600,​8,​N,​1":​serout%=serin%     serin%=OPENUP"​COM1:​ 9600,​8,​N,​1":​serout%=serin%
 +</​code>​
 you must be careful not to close both **serin%** and **serout%**,​ as both variables point to the //same// channel. The following will give an error when trying to **CLOSE#​serout%** as it is trying to close an already closed channel:​\\ ​ you must be careful not to close both **serin%** and **serout%**,​ as both variables point to the //same// channel. The following will give an error when trying to **CLOSE#​serout%** as it is trying to close an already closed channel:​\\ ​
 +<code bb4w>
     CLOSE#​serin%:​CLOSE#​serout%     CLOSE#​serin%:​CLOSE#​serout%
 +</​code>​
 Code similar to the following should be used, also using the code to prevent multiple cascading errors on closing (see [[/​Forcing%20a%20variable%20to%20exist|Forcing a variable to exist]]):​\\ ​ Code similar to the following should be used, also using the code to prevent multiple cascading errors on closing (see [[/​Forcing%20a%20variable%20to%20exist|Forcing a variable to exist]]):​\\ ​
 +<code bb4w>
     IF serin%=serout% THEN serout%=0     IF serin%=serout% THEN serout%=0
     IF serin% THEN temp%=serin%:​serin%=0:​CLOSE#​temp%     IF serin% THEN temp%=serin%:​serin%=0:​CLOSE#​temp%
     IF serout% THEN temp%=serout%:​serout%=0:​CLOSE#​temp%     IF serout% THEN temp%=serout%:​serout%=0:​CLOSE#​temp%
 +</​code>​
notes_20for_20risc_20os_20users.txt ยท Last modified: 2018/04/17 17:48 by tbest3112