Go Down

Topic: STRING of 50 NUL (Read 539 times) previous topic - next topic

Richard Parsons

Need to send a string of 50 NUL to wake up printer: cannot not seem to get right code- Any ideas?

AlphaBeta

Code: [Select]
for (int i=0; i<50; i++) { Serial.write(0); } //maybe?

Richard Parsons

It worked using Serial.print but didn't seem to like write.   It woke up the printer
which then went to sleep again!  Very annoying!

BKnight760

#3
Dec 02, 2010, 02:03 am Last Edit: Dec 02, 2010, 02:04 am by BKnight760 Reason: 1
Remember that null is not the same as ASCII zero.

0 ASCII= 48 decimal = 30 hex
null ASCII = 0 decimal = 00 hex

Serial.print(0); will print out an ASCII zero, not a null.
Serial.write(0); *should* get you a null character.

To be sure, you could try:
Code: [Select]

char MyNullCharacter=0x00;
for (int i=0;i<50;i++)
{
Serial.print(MyNullCharacter);
}


That way, you set the character equal to hex 00, which is null for sure.

robtillaart

#4
Dec 02, 2010, 04:57 pm Last Edit: Dec 02, 2010, 04:59 pm by robtillaart Reason: 1
@Richard you asked this also in another thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290618777 and thats called crossposting and some people don't like that as it costs double time For you to write the message, for us to read them, for you to collect answers etc.  I added a message that the discussion is continued in this thread.

Wrt the question, where does the 50 nulls come from? Could you please place a copy of that manual page here? Maybe it need a few more bytes, a checksum, a certain baudrate ?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Richard Parsons

Hi rob & others,
Fair point. New to forum etiquette! I put the question in the other location, then it occured to me that it was in the wrong place i.e. new topic.

I cannot copy the instruction but extract says:
"To wake the printer by a data stream from the host, a certain period of logical "0" is required, typically a string of 50 NUL characters @ 9600 Baud is sufficient. These characters will be lost."

BKnight may have "hit the nail on the head". I think I sent Zeros rather than Nulls. The printer woke up, printed lots of 0, printed some junk and then went back to sleep. I will have a go with BKnights and report back.
Thanks for your input.

Go Up