diff --git a/CMakeLists.txt b/CMakeLists.txt index b3f8a2d..6fb9d98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,3 +33,5 @@ add_executable( demo src/demo.cpp ) add_executable( demo_raw_decode src/demo_raw_decode.cpp ) add_executable( demo_send src/demo_send.cpp ) + +add_executable( demo_send_c src/demo_send.c ) \ No newline at end of file diff --git a/src/demo_send.c b/src/demo_send.c new file mode 100644 index 0000000..8abfc92 --- /dev/null +++ b/src/demo_send.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include + +#include +#include + +#include "can_wrap.h" + +int main( int argc, char* argv[] ) +{ + const char* canChannel = "vcan0"; + const int canSocket = can_connect( canChannel, false ); + + for( int c=0; c<100; ++c ) + { + struct can_frame frame; + memset( &frame, 0, sizeof(frame) ); + + frame.can_id = 0x188; + frame.can_dlc = 4; + + switch( c%4 ) + { + case 0: frame.data[0] = 0b00000000; break; + case 1: frame.data[0] = 0b00000001; break; + case 2: frame.data[0] = 0b00000010; break; + default: frame.data[0] = 0b00000011; break; + } + + printf("0x%X [%X]", frame.can_id, frame.can_dlc ); + for( int i=0; i