; ; Arduino_Read.shell ; ; A DEMO to access the Arduino Diecimila board for reading only. It reads one ; byte at a time about 1 second apart and displays the result on screen. It uses ; the $RC to collect the byte value of which is immediately stored into another ; permanent _varible_ for usage. ; ; For a real AMIGA serial port get the simple add-on board construction from here:- ; ; http://mikeos.berlios.de ; ; Scroll down to "Arduino project (216K) -- Arduino Diecimila board access using MikeOS" ; and download the zipped file to build the simple serial interface board. ; ; An ARexx subscript is generated called SER_READ.rexx which is saved to the T: ; volume to be used inside this script. If you need this script for other uses ; then drag to, say, the C: volume before resetting or switching off the AMIGA. ; ; NOTE:- Read the comments inside this script first and edit it as required. ; ; Allow a high FAILAT as the $RC is used to pass byte sized perameters... ;oO FAILAT 256 ; ; Remove the ";" on the line below to enable the ARexx interpreter if required ; or start it manually... ;SYS:System/RexxMast ; ; Set the only _variable_. SETENV serialbyte 0 ; ; Generate a simple user screen... ECHO "*ec*nAccessing a byte value from Arduino using the default AMIGA OS install." ECHO "$VER: Arduino_Read.shell_Version_0.00.10_Public_Domain_B.Walker_G0LCU.*n" ECHO "Baud Rate = 1200 bps, Buffer = 512 bytes, Handshaking = OFF." ECHO "Parity = None, Bits per charatcer = 8, Stop bits = 1.*n" ; ; Remove the ";" on the line below to set up the serial port if required... ;PREFS:SERIAL ; ; Generate an ARexx script to grab the port one byte at a time... ; Create an initial, empty file. ECHO > T:SER_READ.rexx ; ; NOTE:- ECHO "" > T:SER_READ.rexx would generate a file 1 byte in size ; containing a newline character... ; ; Now build the ARexx script to read the serial port. ECHO "/** $VER: SER_READ.rexx_Version_0.00.10_Public_Domain_B.Walker_G0LCU. **/" >> T:SER_READ.rexx ECHO "OPEN(ArduinoByte, 'SER:', 'R')" >> T:SER_READ.rexx ECHO "MyByte = READCH(ArduinoByte, 1)" >> T:SER_READ.rexx ECHO "IF MyByte = '' THEN MyByte = 0" >> T:SER_READ.rexx ECHO "CLOSE(ArduinoByte)" >> T:SER_READ.rexx ECHO "EXIT C2D(MyByte)" >> T:SER_READ.rexx ; ; Display the results via the $RC value of AMIGADOS. LAB readloop ; Send any reports to the NIL: device... SYS:Rexxc/RX T:SER_READ.rexx > NIL: ; Immediately copy $RC into another _variable_... EVAL $RC LFORMAT %N > ENV:serialbyte ; Display the result from 0 to 255 inclusive, but, after one grab of value 255 ; quit the loop safely. ECHO "*e[8;1fArduino port value from the return code = $serialbyte... " ; Ensure a getout or use Ctrl-D instead. IF $serialbyte EQ 255 SKIP getout ENDIF SKIP BACK readloop ; ; Getout point. LAB getout ; Remove environment variable and reset the FAILAT value... UNSETENV serialbyte FAILAT 11 ECHO "*nArduino Diecimila board read end!*n" ; ; Arduino_Read.shell DEMO end. ; Enjoy finding simple solutions to often very difficult problems... ;o)