Serial can not transmit binary value of zero

Hi there.

I am having a trouble of not receiving binary value of zero.
Could anybody tell me solution?

[Arduino source code]

...

uint8_t data0 = { 1, 0, 2, 0, 3, 0, 4, 0 };
uint8_t data1 = { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff };
uint32_t n0 = Serial.write(data0, 8 );
uint32_t n1 = Serial.write(data1, 8 );
Serial.flush();
...

The return value of both n0 and n1 is 8.

[Windows source code]

...

DWORD dwRcvSize;
while (1)
{
uint8_t code;
bool bret = ReadFile(m_hPort, &code, 1, &dwRcvSize, NULL);
if (bret && dwRcvSize == 1) printf(" %02x", code);
}
...

[Output]

01 02 03 04 f8 f9 fa fb fc fd fe ff

Thank you.

What happens here if bret is 0x0 ?

if (bret && dwRcvSize == 1) printf(" %02x", code);

Edit:
I have now looked up the Windows C++ ReadFile function. bret in this case is a boolean success code from the read operation.

Edit2:
Without seeing more of the source it is difficult to help. With another Arduino, it would be possible to verify that the success of the send operation. It is possible that, for example, this rule has been violated on the receiving side (from the link above):

When reading from a communications device, the behavior of ReadFile is determined by the current communication time-out as set and retrieved by using the SetCommTimeouts and GetCommTimeouts functions. Unpredictable results can occur if you fail to set the time-out values. For more information about communication time-outs, see COMMTIMEOUTS.

Read the manual: Serial.write send an array to the serial port, and returns the length of the array.

Returns
byte
write() will return the number of bytes written, though reading that number is optional

You send 8 bytes

  uint32_t n0 = Serial.write(data0, 8 );
  uint32_t n1 = Serial.write(data1, 8 );

thus it returns '8'

Thank you.

lesept:
thus it returns '8'

8 + 8 is 16.

But number of bytes I receive is 12. Where are zeros have gone?

2U3:
Thank you.

8 + 8 is 16.

But number of bytes I receive is 12. Where are zeros have gone?

How do you know that the Arduino is not sending the data ?

2U3:
Thank you.

8 + 8 is 16.

But number of bytes I receive is 12. Where are zeros have gone?

Send your data bytes of the two arrays to another Arduino-2 using Software Serial Ports. Print the received bytes on the Serial Monitor of Arduino-2 and don't forget to print the leading zeros. You will be able to see your all (16 bytes) data bytes including the zeros.