Pages: [1]   Go Down
Author Topic: STRING of 50 NUL  (Read 413 times)
0 Members and 1 Guest are viewing this topic.
Oxford UK
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Oxford UK
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 92
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: December 01, 2010, 08:04:14 pm by BKnight760 » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12417
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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 ?
« Last Edit: December 02, 2010, 10:59:58 am by robtillaart » Logged

Rob Tillaart

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

Oxford UK
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: