Hi all,
I used this MCU to transfer CAN data to USB. Now I've one problem. If the program doesn't start in pc side and this MCU receive CAN message and send it to USB host. What will it happen in device side and PC side?
1. Device Side: Can MCU send CAN message to host successfully? Is it will be queued and can't process next CAN message?
2. PC Side : How does the driver work in PC Side?
Now, I can use Win AP to communicate with MCU by USB port and can receive CAN message from MCU. But if the CAN message continue to send to MCU, I can't receive CAN message in Win AP continuously.
My testing architecture:
Another device <- CAN bus-> MCU(MCF51JM128) <- USB -> PC.
Please give me some hint. Thanks a lot.
Regards,
Pogo
What happens if there's no connection or the data rate is too high? You're going to lose data. How? It depends on the software, most of which is in your control. It will do what you write it to do.
If your application requires reliable data delivery, then the protocol stack needs to guarantee this. Part of that requires "flow control".
This needs to work "end-to-end" and not just at some layers. In fact if you are relying on the underlying layers to perform the "flow control" for you, then ALL layers have to be able to do that.
The CAN hardware layer doesn't support any form of flow control. CAN assumes that the system designer guarantees that the "producers" won't ever generate data at a rate than can overload any and all "consumers". CAN is most often used to convey "state" and not "data". As in the "state" of the headlight switch or the current vehicle speed or engine RPM. These only need to be updated somewhere between "every 12ms" (for RPM in GMLAN) or "when they change". CAN guarantees they don't get lost on the wire, and the software guarantees to receive the message and extract the state. Data delivery over CAN is usually limited to updating firmware in a device relies on the software at both ends, sequence numbers, message ACKs and so on.
So your Application probably needs ACKs to be sent back from the far end, and the sender to never get further ahead than the shallowest buffer in the chain. If it is possible to lose data at any level (it is always possible to lose data at any level, but that level may provide its own retry mechanism) then you may need end-to-end retry/resend as well.
If you're used to using TCP/IP to reliably send data, then it is made very simple at the level of your Application because the TCP layer is very complicated in order to guarantee the reliability and flow control. Replacing that functionality with your own protocols is always surprisingly hard.
Tom
Hi TomE,
Thanks a lot for your reply.
I've found one problem on my device. The device's power is not enough to drive the CAN. Now I used power supply to provide power for my device. It works well now.
I have designed my protocal for communication with PC and device. I added some handshakings to guarantee if data has transmitted to device or PC. Thanks for your reply again.
Regards,
Pogo