8devices Community https://www.8devices.com/community/ |
|
Simple c(++)-Example for Windows https://www.8devices.com/community/viewtopic.php?f=16&t=1071 |
Page 1 of 1 |
Author: | Jens_StreetScooter [ 20 Oct 2017, 08:03 ] |
Post subject: | Simple c(++)-Example for Windows |
I am using the CAN2USb for a long time under Linux via socket can and I have created a library / c++14 wrapper to be able to use simple functions / c++-containers (and function callbacks etc.). Now I want to include the possibility to use the code under windows by filling code in "ifdef" blocks*. Is there a simple basic (~20 Lines= example how to use CANAL (CAN Abstraction Layer) API (http://www.8devices.com/media/products/ ... AL_API.pdf) ? Unfortunately the source code of the windows test application does not help me. (http://www.8devices.com/media/products/ ... ce_1_0.zip). *Linux: #include <net/if.h> // can as network layer #include <linux/can.h> // socket can headers #include <linux/can/raw.h> // socket can structs ... ip link set ... ifconfig ... ... //read fd_set readSet; FD_ZERO(&readSet); FD_SET(this->socket, &readSet); if (select((this->socket + 1), &readSet, NULL, NULL, &timeout) >= 0) { if (FD_ISSET(this->socket, &readSet)) { recvbytes = read(this->socket, &frame_rd, sizeof(struct can_frame)); // data is in frame_rd //write write(this->socket, frame, sizeof(struct can_frame)); |
Author: | gedass [ 20 Oct 2017, 12:58 ] |
Post subject: | Re: Simple c(++)-Example for Windows |
Try to look at this: https://github.com/grodansparadis/vscp/ ... /socketcan |
Author: | Jens_StreetScooter [ 21 Nov 2017, 06:54 ] |
Post subject: | Re: Simple c(++)-Example for Windows |
Thank you very much for the hint. Actually this was much more than I was asking for. Some existing cross platform can driver for several hardware would be wonderful but I am afraid that vscp cannot do this. Although there are some “ifdefs” for Windows in https://github.com/grodansparadis/vscp/ ... ocketcan.h it seems to me only be suited for windows – in the *cpp file there are dedicated linux systems headers. In addition wxwidget is used. I want to be able to use can with standard c++(14) only without any need of gui libraries at this level. Thus, knowing how to use the 8-devices windows driver by having a simple basic example would be a good start. Is it right that I have to use the CANAL (CAN Abstraction Layer) API (http://www.8devices.com/media/products/ ... AL_API.pdf) ? Unfortunately the source code of the windows test application does not help me. (http://www.8devices.com/media/products/ ... ce_1_0.zip). |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |