Thursday, April 21, 2022

[FIXED] How to connect two virtual serial ports to read data from GPSFeed+?

Issue

Recently I've downloaded gpsfeed+ file, I set executable attribute and run it with (OS: Manjaro):

$ ./gpsfeed+_amd64\

I'm trying to list all ports connected through a Dart program (code here by using package dart_serial_port), but it lists nothing. I'm assuming it is because of virtual serial ports are not connected, but I don't know how to get this. There is a program like com0com but it works on Windows only.

Any recommendation? Are there other simulators like gpsfeed?

PS: gpsfeed+ is configured to work by using COM3 (protocol RS-232).


Solution

Steps

$ chomod +x gpsfeed+_amd64
  • Install socat package:
$ sudo pacman -S socat
  • Create a pair of virtual serial ports (VSPs) with socat:
$ socat -d -d pty,raw,echo=0 pty,raw,echo=0
  • It displays virtual ports created, in this case: /dev/pts/4 and /dev/pts/5. One port will be transmitter and the another one will be the receiver.
  • Open gpsfeed+ application:
$ ./gpsfeed+_amd64\
  • In Configuration for gpsfeed+ to do:
  1. Connection >> check: Serial, and uncheck: TCP, UDP, Http
  2. Serial/IP >> Port: /dev/pts/4 (transmitter), and Speed: 9600
  • Run simulator (button with a concentric circle as icon)
  • Read data from /dev/pts/5 (receiver)

Python code (install pyserial package):

import serial

ser = serial.Serial('/dev/pts/5', 9600)
iter = 5

while iter > 0:
  print(ser.readline().decode("utf-8"))
  iter -= 1

The very few existing packages for Dart (like dart_serial_port) do not work with virtual ports.



Answered By - Ουιλιαμ Αρκευα
Answer Checked By - Cary Denson (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.