One of communication protocol use Serial.write and I’m facing problems with. Code is:
//All other bytes can simply be copied from the config table
uint8_t response[64];
//npage_size[] is an int type
for (uint16_t x = 0; x < 64; x++)
{
response[x] = *((uint8_t *)pnt_configPage + (uint16_t)(x)); //Each byte is simply the location in memory of the configPage + the offset + the variable number (x)
}
Serial.write((uint8_t *)&response, sizeof(response));
when you plug the the board in the usb port, it should be detected by the os. in linux this can be viewed in lsusb command
i think in windows, you may be able to check that in the device manager
code is at https://github.com/noisymime/speeduino/ … /comms.ino
I’m using Serial.write in some ecu code, but only 1 byte at a time.
Are any bytes sent over serial? Are they wrong? Any serial monitor log available to show the problem?
I would try this way:
Serial.write(response, sizeof(response));
code is at https://github.com/noisymime/speeduino/ … /comms.ino
Didn’t you have some compiler warnings?
Didn’t you have some compiler warnings?
code is at https://github.com/noisymime/speeduino/ … /comms.ino
Are any bytes sent over serial? Are they wrong? Any serial monitor log available to show the problem?
I would try this way:
Serial.write(response, sizeof(response));
19/04/17 16:16:27 :Info: Activating page: 1
19/04/17 16:16:27 :Time: 0:10.602: SENT 2 bytes iwd=10, 2 bytes
x50 x01 P.
19/04/17 16:16:27 :Time: 0:10.613: SENT 1 bytes iwd=10, 1 bytes
x56 V
19/04/17 16:16:28 :Debug: Read page time: 174ms.
19/04/17 16:16:28 :Time: 0:10.763: READ 288 bytes, 288 bytes
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 x00 ................
19/04/17 16:16:28 :Info: Activating page: 2
19/04/17 16:16:28 :Time: 0:10.785: SENT 2 bytes iwd=10, 2 bytes
x50 x02 P.
19/04/17 16:16:28 :Time: 0:10.795: SENT 1 bytes iwd=10, 1 bytes
x56 V
Time: 0:13.797: READ Timout after 0 bytes, Expected:64, actual read:0 Raw buffer
19/04/17 16:16:31 :Debug: Time:13.796s. Instruction:
I’m using Serial.write in some ecu code, but only 1 byte at a time.
Your software is buggy.
I would suggest to get rid (remove) of sizeof(response), and use either previously defined constants or appropriate variables, where needed.
Also, define only once the “response[]” buffer of a maximum size (192?), and control the length of data as said.
Thanks, I will try that
Thanks, I will try that
Serial.write("0123456789", 10); Thanks, I will try that
Did you try changing the line to this as I suggested?
Serial.write((byte *)&response, npage_size[currentPage]);srp


