Good mornig Robert
I have looked at the Control Basic SERINIT, SERINP$ and SEROUT commands and functions, and also studied the example Basic Stamp and Arduino programs on the Parallax website. To me it seems that your program should work, provided all the hardware connections are correct.
Firstly, I tested the syntax of SERINT and SEROUT with the following program:
Code: Select all
SERINIT 0,57600,8,1,0 ' port 0 (USB port), 57600 bps (As Configured), 8 data bits, 1 stop bit, no parity
CR$ = CHR$(13) 'Carrier Return
LF$ = CHR$(10) 'Line feed
x = SEROUT(0, "S") ' Send the Command Code
x = SEROUT(0, "The Quick Brown Fox Jumps over the Lazy Dog") ' Send Text String
x = SEROUT(0, CHR$(13)) ' Send CR
END
This program simply sends The Command Code, the text string and a CR to the Tera Term Console via the on-board USB - Serial interface. In line with the example programs I have sent the Command Code, the text string and the CR seperately, although I don't believe that combining all three into one text string (as you have done) should make any difference.
When I run the program, I get the following display in the Tera Term console:
Control BASIC v0.xx
R-Run S-Step L-List E-Edit C-Configure B-Bank D-Download K-Reset T-Time & Date
Start program
SThe Quick Brown Fox Jumps over the Lazy Dog
Program Ended.
Which shows that the syntax used for SERINIT and SEROUT is fine.
I believe that the following little program should be adequate to coax the desired output from the module, unless I'm missing something:
Code: Select all
PINMODE 36, OUT
PINMODE 37, IN
SERINIT 1,9600,8,1,0 ' port 1, 9600 bps, 8 data bits, 1 stop bit, no parity
CR$ = CHR$(13) 'Carrier Return
LF$ = CHR$(10) 'Line feed
x = SEROUT(1, "S") ' Send the Command Code
x = SEROUT(1, "The Quick Brown Fox Jumps over the Lazy Dog") ' Send Text String
x = SEROUT(1, CHR$(13)) ' Send CR
END
However, the prudent programmer will include a programmatic check for the ":" character to ensure that the module is ready to receive a command.
Such a program may look like this:
Code: Select all
PINMODE 36, OUT
PINMODE 37, IN
SERINIT 1,9600,8,1,0 ' port 1, 9600 bps, 8 data bits, 1 stop bit, no parity
CR$ = CHR$(13) 'Carrier Return
LF$ = CHR$(10) 'Line feed
REPEAT
x=SEROUT(1, CHR$(13)) ' Send a CR to Emic and
x$= SERINP$(1, 1,ASCII(":"),50000) ' check if a ":" is returned
' to show Emic is ready to receive
UNTIL x$ = ":" ' a command
' Send command, text string and CR to module.
x = SEROUT(1, "S") ' Send the Command Code
x = SEROUT(1, "The Quick Brown Fox Jumps over the Lazy Dog")
x = SEROUT(1, CHR$(13)) ' Send CR
END
As I said before, I don't have access to an EMIC2 module, so there is no way that I can test the integrity of my code snippets.
Have a great evening!!!
Regards
Andries