Hi im sniffing packets from canbus and sending the packets to my phone using Access Point. But its really slow since the vehicle sends out around 600 packets/second and the app only recieves 65packets/second.
I tried cleaning the code which helped a bit, went from 37 > 65 packets/second?
Is this because of my hardware or just by using tcp?
What happens with all the lost packets?
Im using r4wifi & mcp2515
void loop() {
client = server.available();
if (client) {
while (client.connected()) {
int packetSize = CAN.parsePacket();
if (packetSize) {
unsigned long PacketId = CAN.packetId();
byte buf3[8];
int i = 0;
while (i < 8 && CAN.available()) {
buf3[i] = CAN.read();
i++;
}
// Combine header, ID, and data into canFrameBuffer
memcpy(canFrameBuffer, RD_FRAME_HEADER, 4);
memcpy(canFrameBuffer + 4, (const byte*)&PacketId, 4);
memcpy(canFrameBuffer + 8, (const byte*)buf3, 8);
// Send the entire CAN frame to client
client.write(canFrameBuffer, 16);
}
}
client.stop();
Serial.println("client disconnected");
}
}