what is extra 2 byte?

Hello. I just joined you.
my problem is that .. i only serial port
I want to send dec = 255 hex = ff. but how do i prevent it from sending an extra 2 bytes through the serial port of arduino.

test.ino (209 Bytes)

Adsız.png

Do you think that Serial.println(""); prints nothing ?

If your puzzled by the results of a commnad look it up.

For the Serial.print reference do a Google search on;

Arduino Serial print reference

And it will tell you what Serial.println actually does.

@OP

Upload the following sketch; carefully, observe the results on Serial Monitor; try to understand the role played by this line:

Serial.println("");

The codes for uploading

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  byte serialArrayOne[] = {255, 255, 255};
  for (int i = 0; i < 3; i++)
  {
    Serial.print(serialArrayOne[i], HEX);//((uint8_t*)serialArrayOne, sizeof(serialArrayOne) );
    Serial.print(" ");
  }
  
  delay(1000);
  Serial.println("");
}

sm104.png

BTW: Recall the functioning of old type writer -- the print head returns to the home position (called carriage return) and then the paper goes 1-line up (called line feed or newline). FF FF FF has come in a line; we want to see the next batch of FF FF FF in the next line. How to do it? We need equivalent soft codes for 'carriage return' and 'newline' which are 0x0D and 0x0A respectively. The execution of 'Serial.println();' simply sends the said two bytes as UART frames one after another. Serial.println(); can be replaced by the following two lines:

Serial.write(0x0D);
Serial.write(0x0A);

sm104.png

thank you so much.
This is the project I want to do.
I listened to the serial port information of a system that sends references to 15 slave systems between 0-255. and I have obtained information as follows.
want to send this information through serial port.
02 00 11 69 01 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 78 06 00 00 00
This is the system running when I copy and send the above information back.
I get this result when I examine.

I couldn't figure out what this data format was.
02 00 11 69 => fixed
01 => slave start address
ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 => 15 slave adress 15 referance data
78 => it's like crc code, but I don't understand, but there's a relationship.
if ((slave start address + data1 + data2 + data3 + data ..... 15 + 122) <= 256)
{
thisbyte = (slave start address + data1 + data2 + data3 + data ..... 15 + 122);
}
else
{
thisbyte = (256 % (modus) (slave start address (01) + data1 + data2 + data3 + data ..... 15 + 122))
If the total of 15 data is not greater than 255 crc byte it is the value of that value.
but if the total value is greater than 255, it takes the result of 256 parts of the total value.
Finally

06 00 00 00 => I did not understand that.

The system is working with rs232.
It's similar to the modbus rtu but that's not exactly it.
I can't figure out what this protocol is.

thank you very much... :slight_smile:

Adsız2.png

example
02 00 11 69 01 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 78 06 00 00 00

02 00 11 69

01 => dec 1

ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 => dec 255+255+255 = 765

78 => dec 120

06 00 00 00

slave start adress + data1 to data15 +122

1+765+122 = 888

256 modus 888 = 120 => HEX 78???

WHAT İS THİS COMMUNİCATİON PROTOCOL??