0

I have a spec sheet for a device which consists of commands that I need to write to the device via CAN bus in order to interact with it. I will be implementing these commands in C++ and write them from a PC into the device via USB -> CAN adapter.

For each command in the spec sheet I am given values for MESSAGE ID, THE PERIOD OF TRANSMITTER(ms), MESSAGE LENGTH(byte), BYTE POSITION, BIT POSITION(start bit), DATA LENGTH(bit).

I am familiar with the CAN bus idea and it’s different frames. Although I am not quite sure how to build and write a command message to the device.

I am thinking the above values are what’s needed in order to construct a command and send it to the device. Although I am not sure what these value names mean nor what CAN bus frame to use.

If someone with CAN bus communication experience could assist with my problem I will greatly appreciate it.

TLDR How can I construct a CAN bus command in C++, what do the above values mean, and do they need to be included in the command?

Jcan1995
  • 39
  • 8
  • How is your USB<->CAN adapter detected by OS? Maybe virtual COM port? Does it have some SDK? – Flanker Nov 23 '16 at 06:00
  • Sorry, but at the moment this is far too broad. You're talking about some unnamed device, which you interface to using some unnamed USB/CAN adapter, using an unknown API. At this point you really should not care about C++. That's not your problem. – MSalters Nov 23 '16 at 08:27
  • Your question is way too vague. Suggestion: Usually, the vendor of the USB-CAN adapter will provide an API and some examples. Use these as a starting point. Since you're familiar with CAN, you should be able to detect its patterns in the example code and from there you can adjust it to suit your particular device. – Ulrich Eckhardt Nov 23 '16 at 08:30
  • @UlrichEckhardt Apologies for the vagueness. Do you have any suggestions for a USB-CAN adapter that comes with a simple API? I'm guessing these APIs implement functions in which build CANbus messages. – Jcan1995 Nov 24 '16 at 03:08
  • Sorry, no. I have read an introductory text to CAN, but apart from that I have zero experience with that system. I was under the impression that you already have an adapter though, did I misunderstand you? – Ulrich Eckhardt Nov 24 '16 at 10:47
  • @UlrichEckhardt I don't have one yet. I'm shopping around to see what the best option would be. I also have zero experience with CAN communication. – Jcan1995 Nov 24 '16 at 21:36

0 Answers0