Re: Virtual Serial Port


 

The answers in

https://stackoverflow.com/questions/52187/virtual-serial-port-for-linux

explain setting up a socat to create a virutal serial pair of ptys for your applications to use.

On Thu, Apr 12, 2018 at 4:02 PM, Max via Groups.Io <kg4pid@...> wrote:
That's a lot to take in. It'll take me a while to study it all. I may need more help.

Thanks, Max KG4PID


On Thursday, April 12, 2018, 12:18:59 PM CDT, Niels Ruiter <pd9q@...> wrote:

Hi Max,

You can use kissnetd of socat…

 

       # link local pi8lap (xnet)

        echo "Starting ax2 "

        if grep ax2 /etc/ax25/axports ; then

        tmpfile="/tmp/$$.startax2.pts"

        kissnetd -p 2 > "$tmpfile" &

        sleep 2

        attachthem () {

                read PTS1 PTS2

                kissattach -l $PTS1 ax2 44.137.31.73 || return=$rc_failed

                ifconfig ax2 44.137.31.73 netmask 255.255.255.224 up

                sleep 1

                sed -i "s,attach sdev3 kiss 3 1 19200 /dev/.*$,attach sdev3 kiss 3 1 19200 $PTS2," /usr/local/xnet/A$

        }

 

        tail -n 1 $tmpfile | attachthem

        rm $tmpfile

        sleep 3

        else

                echo  "Error ax2 not found in the file axports"

               return="Failed"

        fi

        echo "$1 $return"

 

Now socat

 

        # create axudp device

        socat -d -d -ly PTY,link=/dev/ttyq2 PTY,link=/dev/ptyq2 &

        sleep 2

        echo "Starting ax4 "

        if grep ax4 /etc/ax25/axports ; then

                kissattach -m 256 /dev/ptyq2 ax4 44.137.31.73 || return=$rc_failed

                ax25udp -c /etc/ax25/ax25ipd-10093.conf > /tmp/axudp

                ifconfig ax4 44.137.31.73 netmask 255.255.255.224 up

        sleep 1

        else

                echo  "Error ax4 not found in the file axports"

                return="Failed"

        fi

        echo "$1 $return"

 

So little simpler…

 

socat -d -d -ly PTY,link=/dev/ttyq2 PTY,link=/dev/ptyq2 &

 

This create two virtual comports.

 

Hope its helps.

 

73 Niels PD9Q

 

 

Van: RaspberryPi-4-HamRadio@groups.io [mailto:RaspberryPi-4-HamRadio@groups.io] Namens Max via Groups.Io
Verzonden: donderdag 12 april 2018 15:22
Aan: Raspberry 4-Ham RADIO
Onderwerp: [RaspberryPi-4-HamRadio] Virtual Serial Port

 

I need a virtual serial port, let me explain. For some time now I have been sending weather data to aprx by using a Microchip Pic connected to a TTL to USB converter. The Pic receives the weather data from my Davis weather station and adds a kiss header so that it looks like it was received via a tnc. That data was then fed into aprx. In aprx I just added a fake tnc port and it didn't know the difference.

 

I'm slowing building my own weather station with sensors and python on a Pi. For now it is on a separate Pi and I'm using two TTL to USB converters connected back-to-back. First I would like to replace the serial link with a network connection if possible. If / when I get the software finished I would like to move it to the same Pi that aprx is running on and will need two virtual serial ports also connected back to back. Socat or Netcat may work but I don't know how to set this up. It must be able to pass a kiss packet unaltered.

 

Is all this clear as mud? 

 

Max KG4PID

 

 




--


John D. Hays
Edmonds, WA
K7VE

   

Join RaspberryPi-4-HamRadio@groups.io to automatically receive all group messages.