'---------------------------------------------------------------------------------------- ' Name: BAUD_CONV.TIG ' Type: TIGER-BASIC(tm) Source Code ' Purpose: Example of a generic baudrate converter with the BASIC Tiger ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' This short example program was compiled with TIGER-BASIC 5.01 to run with a ' BASIC Tiger Module on the Plug & Play Lab. ' ' It demonstartes how to use the Tiger as a generic, transparent baudrate converter. ' ' The program sends & receives on both serial ports, whereby both ports are working ' with different baudrates. The internal buffer for the serial ports is 2 kbyte. As ' Ser1 does not have any handshake lines, a buffer overflow must be prevented by ' software: The input buffer is always emptied (read into a string), the output buffer ' is only filled up to its maximum size. If more characters have to be send as space ' is avaiable in the output buffer, only so many are written as space is avaialble - ' the remaining characters are dismissed. Additionally an error message (*OVERFLOW*) ' is written. ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' variables must be declared #INCLUDE DEFINE_A.INC ' general definitions #INCLUDE UFUNC3.INC ' User Function Codes TASK MAIN ' begin task MAIN STRING conv0$(2k), conv1$(2k) ' send / receive strings LONG inbuf0, inbuf1, outbuf0, outbuf1 ' for buffer filling BYTE EVER ' for endless loop INSTALL_DEVICE #SER, "SER1B_K2.TDD",& ' install serial driver with 2K buffer BD_19_200, DP_8N, YES, BD_9_600, DP_8N, YES ' <------Ser Ch-0------> <-----Ser Ch-1-----> ' for each channel: Baudrate, Databit/Parity, Receive-on-Error Flag '---------------------------------------------------------------------------------------- ' These parameter can also be changed during program execution: ' ' PUT #SER,#0, #UFCO_SET_SERIAL, BD_300, DP_8N, JA ' <- channel-0 ' PUT #SER,#1, #UFCO_SET_SERIAL, BD_38_400, DP_8E, JA ' <- channel-1 FOR EVER = 0 TO 0 STEP 0 ' endless loop conv0$ = "" ' initialize string for Ser0 conv1$ = "" ' initialize string for Ser1 '------------------------------------------------ from here serial ports are read GET #SER, #0, #UFCI_IBU_FILL, 0, inbuf0 ' characters in input buffer Ser0 IF inbuf0 > 0 THEN ' if characters in buffer GET #SER, #0, 0, conv0$ ' put characters into string ENDIF ' GET #SER, #1, #UFCI_IBU_FILL, 0, inbuf1 ' characters in input buffer Ser1 IF inbuf1 > 0 THEN ' if characters in buffer GET #SER, #1, 0, conv1$ ' put characters into string ENDIF ' '------------------------------------------------ from here serial ports are sending GET #SER, #0, #UFCI_OBU_FREE, 0, outbuf0 ' characters in output buffer Ser0 IF LEN(conv1$) < outbuf0 THEN ' if characters to send fit into output buffer PUT #SER, #0, conv1$ ' output string ELSE ' else conv1$ = LEFT$(conv1$, outbuf0 - 10) ' output what fits into buffer conv1$ = conv1$ + "*OVERFLOW*" ' + error message PUT #SER, #0, conv1$ ' output string ENDIF ' GET #SER, #1, #UFCI_OBU_FREE, 0, outbuf1 ' characters in output buffer Ser1 IF LEN(conv0$) < outbuf1 THEN ' if characters to send fit into output buffer PUT #SER, #1, conv0$ ' output string ELSE ' else conv0$ = LEFT$(conv0$, outbuf1 - 10) ' output what fits into buffer conv0$ = conv0$ + "*OVERFLOW*" ' + error message PUT #SER, #1, conv0$ ' output string ENDIF ' NEXT ' end of endless loop END ' end of task MAIN