Open CronusElectronics opened 1 year ago
In int VescUart::packSendPayload(uint8_t * payload, int lenPay) there seems to be a redundant copy of the paylaod buffer.
memcpy(messageSend + count, payload, lenPay); count += lenPay;
messageSend[count++] = (uint8_t)(crcPayload >> 8); messageSend[count++] = (uint8_t)(crcPayload & 0xFF); messageSend[count++] = 3; // messageSend[count] = NULL; if(debugPort!=NULL){ debugPort->print("Package to send: "); serialPrint(messageSend, count); } // Sending package if( serialPort != NULL ) serialPort->write(messageSend, count);
Why not simply send the payaod buffer then send the CRC saving memory and (more improtantly to me) clock cycles.
serialPort->write(payload, lenPay); serialPort->write((uint8_t)(crcPayload >> 8)); serialPort->write((uint8_t)(crcPayload & 0xFF));
harder to debug if you remove the debug possibility?
harder to debug if you remove the debug possibility? Hi, I was not suggesting that the debug was removed (I just ommited it for brevity).
In int VescUart::packSendPayload(uint8_t * payload, int lenPay) there seems to be a redundant copy of the paylaod buffer.
memcpy(messageSend + count, payload, lenPay); count += lenPay;
Why not simply send the payaod buffer then send the CRC saving memory and (more improtantly to me) clock cycles.
serialPort->write(payload, lenPay); serialPort->write((uint8_t)(crcPayload >> 8)); serialPort->write((uint8_t)(crcPayload & 0xFF));