forked from windelbouwman/virtualcan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (27 loc) · 837 Bytes
/
main.cpp
File metadata and controls
34 lines (27 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "can_connection.h"
#include <stdio.h>
int main()
{
printf("Demo virtual can usage\n");
virtualcan::ICanConnection* can_connection = virtualcan::open_connection("127.0.0.1", 18881);
int i;
for (i = 0; i < 20; i++) {
virtualcan::CanMessage* msg = new virtualcan::CanMessage();
msg->id = 1337;
msg->data[0] = 1;
msg->data[1] = 13 + i;
msg->extended = 0;
msg->data_size = 2;
print_can_message(msg);
can_connection->Send(msg);
}
virtualcan::CanMessage* msg2 = can_connection->Recv();
virtualcan::print_can_message(msg2);
delete msg2;
// receive some messages:
for (i = 0; i < 10; i++) {
msg2 = can_connection->Recv();
print_can_message(msg2);
delete msg2;
}
}