Sending a "multi-byte" packet

I'm trying to send a multi-byte packet through serial. At this point I'm able to get some results in the serial monitor but it's not correct...

I'm getting " n " in the serial monitor.
I know (n) = (6E) in hex value... but where's the rest? Somethings not right.

The packet structure should look like this:

[Process] || [Status] || [Reserved] || [Function] || [Byte Count] || [CRC1] || [Data] || [CRC2]

[ 0x6E ] || [ 0x00 ] || [ 0x00 ] || [0x0B] || [0x00 0x02] || [0x0F 0x08] || [0x00 0x01] || [0x10 0x21]


#include <stdio.h>
#include <util/crc16.h>

int PACKET_CNT = 0;


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

void loop()
{
  
          if(PACKET_CNT < 1 ) // SEND THE PACKET ONCE.
          {
             send_packet(); 
             PACKET_CNT++;
          }
  
}// end loop


void send_packet(){
/*  
//Command
static byte CMD1[] = {0x6E, 0x00, 0x00, 0x0B};
 
  //START OF PACKET
  Serial.print("<SOP> "); //debug

  Serial.write(CMD1, sizeof(CMD1));

  //END OF PACKET
  Serial.print(" <EOP>");
 }

I'm getting " n " in the serial monitor.
I know (n) = (6E) in hex value... but where's the rest? Somethings not right.

What's not right are your expectations.

You are sending 0x6E, 0x00, 0x00, 0x0B as binary data. The serial monitor is expecting ASCII data. The 0x00s and 0x0B are non-printing characters, so your expecting them to print is not realistic.

So I am going in the right direction? The whole CMD is being sent, just NUL (0x00) and (0x0B) are not viewable by the serial monitor?
would you see non-printable characters on the oscilloscope?

would you see non-printable characters on the oscilloscope?

if they weren't printed on the scope, how would you seem them? oh, wait, you mean would the data toggle the serial pin? well. certainly the null bytes won't. the other bytes should.

Have you noticed that it is much harder to read stuff where proper capital letters are not used?

Why not just use a PC terminal program that can be told to display 'pure' binary or hex characters?

Why not just use a PC terminal program that can be told to display 'pure' binary or hex characters?

good call lefty! :wink:

PaulS :

Have you noticed that it is much harder to read stuff where proper capital letters are not used?

Well, I find that it is a lot more easy to decypher my code (in CAPS) from most standard Arduino code during develoment stages.

I would then rewrite the code, revise and optimize if possible.