Go Down

Topic: Serial.write(0x00) issue. Solved. Doc change suggestion. (Read 3859 times) previous topic - next topic

acolyte

I was quite perplexed when I tried to send a null byte (0x00) over the Serial interface. After reading http://arduino.cc/en/Serial/Write  I tried
Code: [Select]
Serial.write(0x00);
and got this error returned..
call of overloaded 'write(int)' is ambiguous

It turns out that I had to do this...
Code: [Select]
Serial.write((byte)0x00);

This is something that might be nice to add to the reference docs.

retrolefty


I was quite perplexed when I tried to send a null byte (0x00) over the Serial interface. After reading http://arduino.cc/en/Serial/Write  I tried
Code: [Select]
Serial.write(0x00);
and got this error returned..
call of overloaded 'write(int)' is ambiguous

It turns out that I had to do this...
Code: [Select]
Serial.write((byte)0x00);

This is something that might be nice to add to the reference docs.


That problem and that solution has been posted before. It showed up with Arduino IDE release 1.0. I'm pretty sure they have a fix that will be released in the next IDE release in a month or so that casting fix should not be needed there after.

Lefty


Osgeld

I just ran into this today, so its still not fixed on 1.0.1
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Slavka85

    So what the f is the solution????... Im in this problem now

LarryD

The way you have it in your schematic isn't the same as how you have it wired up!

Slavka85

Serial.write((byte)0x00);
Good thank you...

  But a what to do with others like 1E same?  Or can be left like that Serial.write(0x1E);

Nick Gammon

Why don't you try it?

Code: [Select]

 Serial.write(0x1E);


See if that works, and then report back to us.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Slavka85

Serial.write(0x1E); works like that
Serial.write((byte)0x00); works only like that

Nick Gammon

So what the f is the solution????... Im in this problem now
What version of the IDE do you have? It seems to compile OK for me under 1.0.6.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Slavka85

What version of the IDE do you have? It seems to compile OK for me under 1.0.6.
1.0.6 ... They saying it will be fixed next IDE.  Seems like its happaning like 2 years now... But its ok if here is a solution...

Nick Gammon

But he was referring to the next version from 1.0.1.

Can you post full code, that demonstrates the problem, which occurs in 1.0.6?

This compiled for me, under 1.0.6 without errors:

Code: [Select]
void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  Serial.write (0x00);
  }  // end of setup

void loop () { }
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up