Create virtualport - StevenMacias/velociruabtor_v2 GitHub Wiki
Creating socket connection to develop without board:
-
- To create a virtuak port you can use the following command:
socat -d -d pty,raw,echo=0 pty,raw,echo=0
-
- The command return us the next log, where you can find the two bidirection ports connected(/dev/pts/2 and /dev/pts/3)
2019/05/04 11:59:38 socat[8082] N PTY is /dev/pts/2
2019/05/04 11:59:38 socat[8082] N PTY is /dev/pts/3
2019/05/04 11:59:38 socat[8082] N starting data transfer loop with FDs [5,5] and [7,7]
-
- Now all we need to do is inject the JSON in one port and read the other one with the code.
IMPORTANT! You must send data before reading the other port by code.
EXAMPLE:
- Step 1) Creating the socket bidirectional connection:
socat -d -d pty,raw,echo=0 pty,raw,echo=0
..
..
..
2019/05/04 11:59:38 socat[8082] N PTY is /dev/pts/2
2019/05/04 11:59:38 socat[8082] N PTY is /dev/pts/3
2019/05/04 11:59:38 socat[8082] N starting data transfer loop with FDs [5,5] and [7,7]
- Step 2) Once we had the connection opened, we inject JSON data to /dev/pts/2
echo "{"xAccel":-0.146,"yAccel":-0.127,"zAccel":0.98,"array_calib_min":[219,169,2500,2500,2500,2500],
"array_calib_max":[2500,2500,2500,2500,2500,2500],"array_values":[50,00,70,80,90,10],
"array_position":0,"PWMA":255,"AIN1":0,"AIN2":1,"PWMB":128,"BIN1":1,"BIN2":0,"STBY":1}" > /dev/pts/2
- Step 3) Now we can run our code which is connected to /dev/pts/3