A repository of basic codes and usage instructions for Mokar V2X devices. The project is sponsored by Shanghai Jiaotong University.
Here are some introductions and tutorials for the V2X device. Honestly speaking, I 'm just a beginner in this field. My document and tutorial contain only some basic ways to code & run programs on the V2X device.
- Description
- Installation
- Hardware Connection
- Before Communication
- Samples
- Coding
- TCP Communication
- Other Problems
- Contact
Folder tree:
.
├── mde --SDK provided by Mokar Technology
│ └── mocar
│ ├── bin --Compiled files here
│ ├── build --Make file here
│ ├── docs --Documents by Mocar
│ ├── libs --Library
│ ├── license --License
│ └── samples --Some sample codes by Mokar, except Lidar_send and Lidar_recv generated by Fantasticos
└── TCP_Scripts --TCP communication code
├── test_tcp_1 --Old version 1
├── test_tcp_2 --Old version 2
├── test_tcp_3 --Latest version
└── test_tcp_3 (copy) --Copy of old version 3
mde is a developing kit provided and copyrighted by Mokar Technology.
TCP_Scripts contains some simple programs and their codes for socket TCP communication between computer and Mokar V2X devices.
To clone the codes from Github
$ cd /your_own_work_space
$ git clone https://github.com/Fantasticos/V2X_SJTU.git
Install arm-linux-gnueabihf cross compiler
Download compiler
Move .tar to /opt
Extract
$ tar -xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar
Modify profile
$ cd /etc
$ sudo gedit profile
add export PATH=$PATH:/opt/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin
$ sudo gedit ~/.bashrc
add source /etc/profile
reboot the terminal
Refer to the handbook
If you want to connect by Wifi, search for Wifi AP named "IMASTERXXXX", default device ip address 192.168.10.1
If you want to connect through Ethernet, change your local ip address to be 192.168.253.1 and wire-connect directly to the Mokar device, or through a switch. Default device ip address 192.168.253.10
Suppose you connect through a wire, so the ip address of V2X device is 192.168.253.10. If you connect wirelessly, just replace the ip with 192.168.10.1
IMPORTANT
You should change your ip address according to your target address. For example, if you want to connect to 192.168.253.10 with Ethernet, you have to change your own ipv4 address to be 192.168.253.x, x can be replaced by any integer from 0 to 255 except 10 (you cannot set your ip to be identical with your device's)
Before you test the communicaiton, you have to upload the essential libraries.
$ cd mde/mocar/libs
$ scp libmocarv2x.so [email protected]:/usr/lib/
$ scp base/libasnhl.so [email protected]:/usr/lib/
$ scp base/libosstoed.so [email protected]:/usr/lib/
$ scp base/libLLC.so [email protected]:/usr/lib/
$ scp base/libstack.so [email protected]:/usr/lib/
$ scp base/libsmartway.so [email protected]:/usr/lib/
$ scp ../samples/mocar_log.conf [email protected]:/usr/local
PASSWORD: hL2017.moKar
The sample codes are in mocar/samples
, you can compile the sample under mocar/build
$ cd mde/mocar/build
$ make
Upload the sample app to the v2x device, take bsm for example
$ cd ../bin
$ scp bsm [email protected]:/var
Open a new terminal, log into the device through SSH
$ ssh -l root 192.168.253.10
PASSWORD: hL2017.moKar
Enter /var
and run the sample app
# cd /var
# ./bsm
If warn undefined symbol: mde_stack_init
, just remove usr/local
and upload the .conf file again.
# rm -rf /usr/local/*
$ scp ../samples/mocar_log.conf [email protected]:/usr/local
Now you can see the device sending bsm message at 10 HZ.
You can repeat this process and upload program to another Mokar device, run the same ./bsm
, you can definitely see the two device communicating!!!
The coding work now take place in mocar/samples
Two example are provided, lidar_send and lidar_recv. I wrote these two program for my graduation project. They combine TCP communication and BSM message sending and recving.
To generate your own code, I suggest you to copy one sample, like bsm, copy the folder and rename the folder. Also remember to replace the code file name and the name in makefile.
Now you can add any funcion you like!!!
The communication between computer and V2X device is done by TCP.
In TCP_Scripts, programs include client and server, client runs on the computer and server runs on the device.
In my project, the tcp server is merged into samples/lidar_send
and samples/lidar_recv
. lidar_send is for the Road Side Device, while lidar_recv is for the On Board device
To test, you can upload lidar_send or lidar_recv to the device, then move to test_tcp_3
,run
$ ./client 192.168.253.10
or you can replace the ip address with 192.168.10.1 if connected through Wifi
Synchronization of clock
To make sure that the clock are at the same pace, I use NTP to synchronize it.
The NTP server should be installed on your own computer, you can google it yourself, there are plenty of tutorials.
The problem is that the compilation of NTP client in the device is difficult because it use gcc-linaro-arm-linux-gnueabihf to compile files. To make this step easy, I compiled the client on my computer and just share the executable
$ cd NTP/ntpclient-2015
$ scp ntpclient [email protected]:/var
If you have finished the construction of NTP server on your own computer, you can run the following code on the device, and you can see your clock synchronized.
./ntpclient -s -d -c 1 -i 5 -h 192.168.253.1
If you have any questions, feel free to email me. My email address is [email protected]