Echoing the comments from above - consider this minor variation in your architecture:
// +---- Device # 1 ---+ +---- Device # 2-----+ +--- PC --+
// mbed -- CAN Xcvr 1 ==== CAN Network ==== CAN Xcvr 2 -- mbed == USB Cable == PC
//
//
// +---------------- In the mbed module -------------------+
// can.read() -> buffer -> pc.printf()
// can.write() <- buffer <- pc.isreadable() ... pc.getc()
Device #1 could be an LPC1768 based mbed for instance, simply generating traffic, or a real device (e.g. OBD2 port on a car). Device #2 is then the 2nd CAN port (again on the LPC1768 as an example).
The USB port that you use to program the mbed with can be used as a serial port to the PC. Through this you can run a basic terminal program to see the CAN traffic that the mbed has received and formatted into text.
Of course, a custom PC program could receive a binary stream from the mbed as well.
As my stick-figure shows, there are basically four processes in the mbed module:
- Receive from CAN: When a can message is received, it is placed into a buffer. This minimizes the processing time as this might be performed within a CAN ISR callback.
- Send to PC: This process simply pulls messages from the buffer and formats them nicely for the serial port attached to the PC.
- Receive from PC: Some simple command set lets you create a packet on the PC. This process pulls that down perhaps a character at a time until if has a whole message. It then creates the CAN message and puts it in the buffer.
- Send to CAN: Pull packets from the buffer and send them to CAN.
These 4 processes could be managed with the RTOS, or you could simple collapse them into a polling loop, and then the buffer might not even be required (depending on the speed of each link).
Hello all,
I set up my mbed today on a bread board with two CAN traceivers (MCP2551's) and I'm pretty sure it's wired up properly. I modified the test code slightly to blink LEDs when messages are sent by can1 and another led should show when can2 receives the message.
It appears the messages are being sent but I show no activity on the receiving end? Any help is appreciated...
Here is the code and a picture...