'Test Serial Port Access, display characters in a column 'December 31, 2005 'A PIC14000 device is connected to serial port com2 and is known to work. 'It is set up for 9600 baud, 8 data bytes, no parity, and one stop bit. The data 'is in the form of words each 8 bytes long. Each word begins with a sign and 'ends with a CR and LF, and contains a number as high as 32727. 'An expected data example would be "-00034CRLF", each expressed as a ASCII 'hex number. 'Program stratagy. Access the serial port and extract characters as bytes. 'Each byte will be extracted to an array (sized at 20 bytes for test 'purposes) 'Each array byte will be displayed with a print statement. 'Each array byte will be compared to the previous byte, looking for a difference 'between bytes to ensure that the print statement does not miss unprintable 'characters. DIM buffer(20) AS BYTE DIM anystring AS STRING 'OPEN COM PORT TWO OPEN COM "COM2:9600,N,8,1" FOR BINARY AS #1 'COM2, 9600 BAUD, NO PARITY BIT, EIGHT DATA BITS, ONE STOP BIT, GET #1,,buffer() 'Read the port as a file, place the characters in "buffer()" FOR I = 1 TO 19 print buffer(I) if (buffer(I) <> buffer(I - 1)) then print " Found a difference"; NEXT CLOSE #1 input "Enter CR to end the test. ", anystring$ END 'program now terminates