HowTO: Using XRPi or XRLin with FBB on the same platform 


FBB is evidently a popular BBS for XRouter (a.k.a. XRPi or XRLin) users. There is interest in running XRouter and FBB on the same platform with the ability to communicate directly between the two programs. The intent of this write-up is not to show how to install either XRouter or FBB, but to show what specifically needs to be added to the configuration of each in order for them to communicate while running on the same computer. This method described here is expected to work on either a Linux computer or a Raspberry Pi.

Your truly has very little experience with the FBB BBS software, so there's no claim here to be an expert. However it's probably safe to assume that it, like most packet programs, started out interfacing via serial interfaces that were used to connect a computer to a TNC. Fortunately there is a big hint to connecting XRouter and FBB directly in the info available via this URL: https://packet-radio.net/xfbb-interface-with-linbpq/

It is evident in the instructions at the link above that the intent is to interface LinBPQ and FBB while both programs are running on the same platform. The intructions show how to configure BPQ with WA8DED TNC emulator and set up FBB with a WA8DED TNC interface. It appears BPQ's implementation of the emulation is purely as a virtual interface, so FBB would have to be running on the same platform in order to use it.

WA8DED emulation is supported by XRouter, so the same approach can be used.  Unlike the BPQ emulator XRouter supports both physical and virtual interfaces, but also unlike BPQ, XRouter does not create a virtual interface .  Both XRouter and FBB need to use virtual interfaces that are created by some other means -  or already exist.

Fortunately Linux has "pseudo teletype" or "pseudo terminal" functionality, which can be used to link XRouter and FBB (for more details see the forum discussion below as well as the man page).
https://stackoverflow.com/questions/52187/virtual-serial-port-for-linux
https://manpages.debian.org/buster/manpages/pty.7.en.html

We'll start with an example using BSD style pseudo terminals with the caveat that this functionality is depreciated and therefore may no longer be supported by your Linux distribution. First we need to configure an interface in XROUTER.CFG in XRPi or XRLin to facilitate the WA8DED emulation: (example below).  For further details see http://ohiopacket.org/xrpi/docs/dedhost.htm or http://vk2dot.dyndns.org/xrpi/docs/dedhost.htm

The interface number needs to be one that is not already in use. The value of ptyp5 has been selected more or less at random.  Speed is fairly optional ; it appears anything 9600 or above will work.

INTERFACE=5
       TYPE=ASYNC
       COM=/dev/ptyp5
       PROTOCOL=DEDHOST
       APPLNUM=1
       CHANNELS=4
       SPEED=57600
       FLOW=0
       MTU=256
ENDINTERFACE

Next we need an application.  The application name corresponds to the command entered when connected to XRPi or XRLin that will invoke a connection to the FBB BBS. Use your desired APPLNAME, APPLCALL-SSID, APPLALIAS, and APPLQUAL.  The quality range is 0-255.  The APPLCALL value must match the callsign and SSID configured in your fbb.conf file applicable to your implementation of FBB.

APPL=1
      APPLNAME=FBB
      APPLCALL=K5DAT-1
      APPLALIAS=FUNBBS
      APPLQUAL=254
      APPLFLAGS=4
ENDAPPL

Next the FBB configuration (port.sys) file needs to include a WA8DED TNC interface.  Below shows only the TNC/Port applicable to this. The virtual interface needs to be the "tty" member of the selected pair of virual interfaces.  In XRouter the interface is /dev/ptyp5, so in FBB the interface must be /dev/ttyp5 as shown below.

#Ports TNCs
1      1
#
#Com Interface Adress (Hex) Baud
1    9         /dev/ttyp5   57600
#
#TNC NbCh Com MultCh Pacln Maxfr NbFwd MxBloc M/P-Fwd Mode Freq
1    4    1   1      236   4     1     10     00/15   DUWYL XR
 
XRPi or XRLin need to be started before FBB.  In the event that XRPi or XRLin need to be restarted, FBB needs to be shut down first followed by a restart of XRPi/XRLin. Then FBB can be started up again.

In addition to being depreciated, the BSD style pseudo terminals are accessible only from root.  Below is another method by which virtual serial ports can be created using SOCAT, which will allow XRouter and FBB to run under non-root users.  (Also see https://packet-radio.net/xrpi-interfacing-with-linfbb/)

Before running XRouter under a non-root user, Yours Truly normally issues this command from the directory containing the xrpi or xrlin executable in order to enable required networking functionality:

sudo setcap "CAP_NET_ADMIN=ep CAP_NET_RAW=ep CAP_NET_BIND_SERVICE=ep" xrpi

Install SOCAT:

sudo apt install socat

Kill any running socat process:

sudo kill $(ps aux | grep '[s]ocat' | awk '{print $2}')

Create virtual serial ports with socat in your home directory.  Tailor to your system as needed.

socat -d -d -ly PTY,link=/home/pi/xrpi/ttyq1 PTY,link=/home/pi/xrpi/ptyq1

Using the socat example above, the XRouter interface would look like this:

INTERFACE=5
        TYPE=ASYNC
        COM=/home/pi/xrpi/ttyq1
        PROTOCOL=DEDHOST
        APPLNUM=1
        CHANNELS=4
        SPEED=57600
        FLOW=0
        MTU=256
ENDINTERFACE

The FBB port.sys example then would look like this:

#Com Interface Adress        (Hex)    Baud
1    9         /home/pi/xrpi/ptyq1    57600
#
#TNC NbCh Com MultCh Pacln Maxfr NbFwd MxBloc M/P-Fwd Mode Freq
1    4    1   1      236   4     1     10     00/15   DUWYL XR