0

I'm doing a small project where I have two system communicating with each other. Here's a bit of information that might be useful for this question:

  • The language I am using is C, and the game is PONG;

  • I'm using freeRTOS on both systems. (sys1 and sys2, sys 1 has game logic,display, and controller for player1) and the systems are connected trough USB.

  • One system has all game logic, the other one is just a controller for player 2 and also displays some game data (like which player scored or won).

My question is if it's a good idea to do bit checking (for example checksum) when I'm sending data from sys2 to sys1.This data is what moves player2.

Currently it's only checking if the data received is 'a' , and if it is, the player moves. I'm thinking it might be good to implement something, but I couldn't find what would have the least impact on performance. As it is now, Player 2's movements lag when System2 is listening for data from system1.

  • 1
    I don't think you need that for USB connections, since they are pretty stable. But I'll leave the answer to experts, since I never had to handle this kind of problem (corrupt data) before. – Leonardo Alves Machado Aug 15 '18 at 15:31
  • 1
    I would expect that USB chipsets or at least USB drivers should provide some checks for correct data and incorrect data should never reach your application. – Gerhardh Aug 15 '18 at 15:33

1 Answers1

1

If you have actual USB interfaces on both ends, then no need for error checking: the USB frames already include CRCs and USB controllers should ensure the data integrity (unless you're doing isochronous transfers, which are a bad choice for your case). Here is an article with nice pics of USB frames, along with other information:

https://www.totalphase.com/support/articles/200349256-USB-Background

If there is a USB-to-Serial on either end, then it's a different story, but most likely you won't need to worry about errors even then.

Mikhail Iakhiaev
  • 1,107
  • 9
  • 8