Hello, I've got a question about sending serial data on the arduino uno.
As you send serial data from the TXpin to an other device, then that data is shown on the serial monitor with ascii representatives.
Is it possible to show that data in binary representatives in stead?
Do you have to change some things in some specific registers or are there a few other solutions?
I know that if you use :
transmit data = Serial.write (something);
Serial.print (transmit data, BIN);
that you then get the binary version of the ascii data but also the ascii data itself on the screen.
And because the serial monitor is connected to the TXpin, that all the info you show on the screen is also send trough the TXpin (and in my example an other device).
So to sumarise can you get the transmit data on the TXpin on the screen directly in binary in stead of ASCII?
Thx for the help!
As you send serial data from the TXpin to an other device, then that data is shown on the serial monitor with ascii representatives.
That depends on what methods you use to send the data. The Serial object is an instance of the HardwareSerial class, which derives from Stream, which derives from Print.
The Print class has methods that convert values to strings that get sent as chars and methods that send bytes (binary) with no conversion.
Is it possible to show that data in binary representatives in stead?
It is possible to send binary data. The Serial Monitor is not designed to convert that binary data to printable representations.
I know that if you use :
transmit data = Serial.write (something);
Serial.print (transmit data, BIN);
that you then get the binary version of the ascii data but also the ascii data itself on the screen.
This doesn't make sense. The Serial.write() method doesn't return anything of type transmit. The Serial.print() method does not know how to deal with anything of type transmit. The BIN argument defines how to convert the first argument to a string, which is not the same thing as sending binary data.
And because the serial monitor is connected to the TXpin, that all the info you show on the screen is also send trough the TXpin (and in my example an other device).
You've got this twisted around. There is no also about sending serial data. Something needs to receive the data. If that something is the Serial Monitor, you need to send it data that it can understand. That is NOT binary data. If the something that is receiving the data is not the Serial Monitor, the data does not "also appear on the screen" (f the "screen" you are referring to is the Serial Monitor).
So to sumarise can you get the transmit data on the TXpin on the screen directly in binary in stead of ASCII?
No. Doing so makes no sense.
If you want to see the binary representation of your data you need to also send the binary from the arduino, or have code on the recieving end that can process the data and display it in binary.
PaulS:
This doesn't make sense. The Serial.write() method doesn't return anything of type transmit. The Serial.print() method does not know how to deal with anything of type transmit. The BIN argument defines how to convert the first argument to a string, which is not the same thing as sending binary data.
But it does know how to deal with a Printable, which transmit (may) be derived from.
Print.h:
size_t println(const Printable&);
didier_vandeputte:
So to sumarise can you get the transmit data on the TXpin on the screen directly in binary in stead of ASCII?
Thx for the help!
I am assuming that what you want is to see the Binary representation of the 8 bit value sent
over the serial interface.
The answer is yes that is possible, although you cannot do it with the built in serial monitor in the Arduino IDE.
You will need to use a different serial monitor/terminal emulator.
Some will allow you save the data transfered. Then you can look at it with a hex editor.
On Windows you can even use PortMon to see the raw bytes moving back and forth on the serial interface.
---- bill
But it does know how to deal with a Printable, which transmit (may) be derived from.
Even if transmit did derive from Printable, the statements:
transmit data = Serial.write (something);
Serial.print (transmit data, BIN);
still don't make sense. The Serial.write() function returns an int, which may, or may not be storable in a transmit object.
For the sake of argument, let's assume that it is. The print() method call is still bogus. It is no different from:
Serial.print(int thing, BIN);
Serial.print(long thing, BIN);
Serial.print(char thing[], BIN);
etc., all of which are clearly invalid syntax. And nonsense.
The point behind my post was to primarily indicate that less hand waving and more code posting was necessary.