Invalid Serout strings.

russbow

Senior Member
I am attempting to serout a string to a speakjet chip.

This program fails syntax.

Code:
#picaxe18m2

do

serout c.1,t2400,("\NO \OW \VV \FAST \EH \MM \EB \FAST \AXRR" )

pause 2000

loop
Error message is Error: Unrecognised escaped char 0x4E after \ character. For \ type \\.

I suspect is has something to do with the backslash characters. These need to be sent to the speakjet, I think as control characters.

If I use \\ instead or \ what will actually be sent.
 

nick12ab

Senior Member
I suspect is has something to do with the backslash characters. These need to be sent to the speakjet, I think as control characters.

If I use \\ instead or \ what will actually be sent.
Yes it is to do with the backslash characters. The backslash character is an escape character and can be followed by certain other characters to create a control code. For example, "\n" is the same as LF. If you want a backslash character, you must use two backslashes and the PICAXE will transmit one backslash.
 

Buzby

Senior Member
I know there are hundreds of '\' escape codes, but where is the list of the ones that PE supports ?
 

nick12ab

Senior Member
I know there are hundreds of '\' escape codes, but where is the list of the ones that PE supports ?
I could not find a list on the PICAXE website so it looks like you'll have to just guess.

\" will represent a " character and that can be used in commands like serout but the colour syntax won't show this.

It doesn't matter anyway since it only works when writing code where you could just terminate the string with ", then specify the control command number. It doesn't work in the terminal where it would actually be very useful.
 

westaust55

Moderator
Are the escape characters listed anywhere ? I knew of \n, but no others.
Not in the PICAXE manuals and some equipment manufacturers assign their own purposes to some codes.

However, if you open the Programming Editor and then from the toolbar click "Help/ASCII Table" the control codes/characters are the 32 codes with the abbreviation in brackets () in the left most column. There is also the code 127 = Delete.

Think in terms of Ctrl=@ = 0, Ctrl-A = 1, Ctrl-B = 2, ... and Ctrl-N = 14 which is the control code for (SO = Shift Out).
Have a look here for the "standard" meaning of these codes.


Some of these such as Ctrl-H = 8 (Backspace) work with most character based LCD displays
Rev Ed uses \n as a newline control code

From Wiki:
In computing a newline, also known as a line break or end-of-line (EOL) marker, is a special character or sequence of characters signifying the end of a line of text.
The name comes from the fact that the next character after the newline will appear on a new line—that is, on the next line below the text immediately preceding the newline.
The actual codes representing a newline vary across operating systems, which can be a problem when exchanging text files between systems with different newline representations.

PICAXE Manual 1 Tutorial 8 does advise of two pre-defined control codes:
The CR and LF constants are pre-defined values (13 and 10) that cause the
serial terminal to display a newline for each value so that the display updates correctly.
Additionally, some of these such as Ctrl-H = 8 (Backspace) work with most character based LCD displays
Rev Ed uses \n as a newline control code.


Within the Programming Editor as of V5.5.0 (from the revisions.txt file) we also know that:
Added _\n (whitespace-underscore-newline) as line continuation for splitting long lines
 
Top