linklayer / cantact

Drivers and Command Line Interface for CANtact tools
http://cantact.io
MIT License
46 stars 11 forks source link

Cantact C reference #5

Closed elliotwoods closed 3 weeks ago

elliotwoods commented 3 years ago

Heya !

So now I'm trying to get things working in a simple C/C++ app which imports the DLL Some functions work (Receive callback, counting devices). But the device crashes when sending a message with transmit.

My code is here: https://github.com/elliotwoods/Cantact.NET/blob/master/NativeTest/CantactNativeTest.cpp I used the BusMaster implementation as a reference.

Sending messages works in cangaroo for me, but I noticed that they use their own driver code there: https://github.com/HubertD/cangaroo/tree/master/src/driver/CandleApiDriver/api

ericevenchick commented 3 years ago

Thanks for reporting this. I'll try building and debugging your implementation.

Are you using a CANtact or CANtact Pro in testing this? They should be the same but it's useful to know.

Also, can you provide any details on the crash?

elliotwoods commented 3 years ago

Hello Eric

Thank you for the quick reply. I must apologise that I'm using the CANable Pro, not the actual Cantact device.

I have started to wrap the Candle code from the Cangaroo repository instead, which is working so far.

Specifically the crash: Receive calls backs work If I try to send a message, then the device stops responding and the application hangs. Restarting the application then doesn't work, I need to power cycle the device before the application can receive messages again

Thank you Elliot

elliotwoods commented 3 years ago

Hi there. I'm about to buy a Cantact Pro from Crowdsupply, but I realized that the processor is not the ST chip, i.e. it is not using the Candlelight FW? https://github.com/candle-usb/candleLight_fw

Does this C API work with the Cantact Pro? https://github.com/linklayer/cantact/blob/master/driver/src/c/cantact.h

And is the firmware on the Cantact Pro compatible with candlelight host C code e.g.? https://github.com/HubertD/cangaroo/tree/master/src/driver/CandleApiDriver/api

I previously wrapped both of these when testing with the Canable Pro: https://github.com/elliotwoods/Candle.NET https://github.com/elliotwoods/Cantact.NET And found the CandleApi to be more stable

You mention that the Busmaster software has an implementation for the Cantact device, but I couldn't find cantact mentioned in the implemented devices of Busmaster, e.g. here: https://github.com/rbei-etas/busmaster/tree/master/Sources/BUSMASTER