Bluepy BLE Disconnecting after receiving several packets from Bluno Beetle - bluetooth-lowenergy

I am required to connect 6 bluno beetles to my Raspi 3B+ to receive some data concurrently. However, with only 1 connection to one bluno beetle, I am already having constant disconnection after receiving a few packets. Sometimes I am able to receive 20 packets before disconnecting, while sometimes I am able to receive 5 packets before disconnecting. The number of packets received fluctuates.
Is this suppose to be normal?
My raspi 3B+ is installed with Raspbian GNU/Linux 10 (buster). I have python3 installed with bluepy version 1.3.0 installed.
The Bluno Beetle is an Arduino Uno based board with bluetooth 4.0
The Raspi 3B+ has a Bluetooth HCI Version: 5.0 (0x9)
I have tried to handle disconnection by reconnecting and it works fine. But the time taken to reconnect takes a while (4-5 seconds) which I would have data from Bluno beetle side.
How can I further enhance the robustness of BLE?
This is my python code below where I am only listening to data sent from the Bluno Beetle.
from bluepy import btle
from bluepy.btle import BTLEException, Scanner, BTLEDisconnectError
import threading
# Global Vars
connectionObjects = [] # Total of 6 Connections expected
connectedThreads = [] # Total of 6 Connections expected
threads = list()
class MyDelegate(btle. DefaultDelegate):
def __init__(self, connection_index):
btle.DefaultDelegate.__init__(self)
def handleNotification(self, cHandle, data):
print("handling notification...")
data_string = str(data)
print(data_string)
class ConnectionHandlerThread (threading.Thread):
def __init__(self, connection_index, BTAddress):
threading.Thread.__init__(self)
self.connection_index = connection_index
self.BTAddress = BTAddress
self.connection = connectionObjects[self.connection_index]
def connect(self):
self.connection.setDelegate(MyDelegate(self.connection_index))
def run(self):
self.connect()
while True:
try:
if self.connection.waitForNotifications(1.0):
continue
print("Waiting...")
except:
try:
self.connection.disconnect()
except:
pass
finally:
reestablish_connection(self.connection, self.BTAddress, self.connection_index)
def reestablish_connection (connection, BTAddr, index):
while True:
try:
print("trying to reconnect with " + str(BTAddr) )
connection.connect(str(BTAddr))
print("re-connected to "+ str(BTAddr) +", index = " + str(index))
return
except:
continue
BTAddress = ['1c:ba:8c:1d:3a:c1']
for index in range(len(BTAddress)):
while True:
try:
p = btle.Peripheral()
p.connect(BTAddress[index], btle.ADDR_TYPE_PUBLIC)
break
except btle.BTLEException as e:
print("Connection Fail. Retrying now...")
continue
print ("Successful Connection to BLE " + str(BTAddress[index]))
connectionObjects.append(p) # first index is 0, first connected is beetle num 1
thread = ConnectionHandlerThread(len(connectionObjects)-1, BTAddress[index])
thread.setName("BLE-Thread-" + str(len(connectionObjects)-1))
thread.start()
connectedThreads.append(thread)
My hciconfig:
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:D4:EC:5D ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:204543 acl:2383 sco:0 events:8342 errors:0
TX bytes:49523 acl:152 sco:0 commands:4072 errors:0
Connecting via bluetoothctl seems fine:
root#raspberrypi:~# bluetoothctl
Agent registered
[bluetooth]# connect 1c:ba:8c:1d:3a:c1
Attempting to connect to 1c:ba:8c:1d:3a:c1
[CHG] Device 1C:BA:8C:1D:3A:C1 Connected: yes
Connection successful
I have been searching around the net for a robust solution but could not find a way to prevent disconnection or increase the reconnection time. Would appreciate if you could help me with this!
Could the reason be RPI firmaware makes BLE unstable?? https://github.com/IanHarvey/bluepy/issues/396

I can conclude that RPI firmware has issue after testing with another board.
Could the reason be RPI firmaware makes BLE unstable??
https://github.com/IanHarvey/bluepy/issues/396
Works without disconnection when tested the same setup with Ultra96 v2 running on Ubuntu 18.04 bionic. I am able to read/write to bluno device every 1ms and the connection is robust.
Hence, it seems like the problem was with RPI firmware. I was using Rasbian Buster on Raspberry pi 3b+.

Related

Problem Flashing nrf52 chip using Openocd

I have a custom nrf52 chip on a pcb with swd pins exposed. I have cloned and installed the latest openocd from https://github.com/ntfreak/openocd. The latest version includes all the latest pathes for the nrf52 chip, so no need for any additional changes as suggested in many older guides online. I am able to connect to the chip using ST-LinkV2. when connected I can read and write memory locations using mdw and mdb. I can also run some basic openocd commands like dump_image e.t.c, which confirms that the setup is good. But halt and program commannds always lead to errors like:
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
JTAG failure -4
target halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 00000000 msp: 00000000
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Previous state query failed, trying to reconnect
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
if I try to use flash image_write I get the error,
JTAG failure
Error setting register
error starting target flash write algorithm
Failed to enable read-only operation
Failed to write to nrf52 flash
error writing to flash at address 0x00000000 at offset 0x00000000
in procedure 'dap'
jtag status contains invalid mode value - communication failure
Polling target nrf52.cpu failed, trying to reexamine
I have read different guides online, and one of the possible solutions involves the APPPROTECT register which has to be disabled to enable any writes to flash.
APP_PROTECT, But the dap commmand which is supposed to help us access this bit,
dap apreg 1 0x04 0x01
returns an error:
invalid subcommand apreg 1 0x04 0x01
Please, I will like to know if anyone has had success programming a new empty nrf52 chip with the stlink-v2 and the steps which are necessary, or if any one has encountered similar problems. Thanks.
Here is my config file:
#nRF52832 Target
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/nrf52.cfg]
#reset_config srst_nogate connect_assert_srst
I solved the "protected nRF52" chip problem this way, on Windows, using a Particle.io Debugger https://store.particle.io/products/particle-debugger setup to program nRF52 chips from Arduino as described in https://www.forward.com.au/pfod/BLE/LowPower/index.html
Note: The recovery process described here does NOT need Arduino to be installed
Download OpenOCD-20181130.7z pre-compiled openocd for windows from
http://gnutoolchains.com/arm-eabi/openocd/
The latest version of openocd src on https://github.com/ntfreak/openocd should also work as it includes the apreg cmd in target\arm_adi_v5.c
unzip, open cmd prompt to unzip dir, enter cmd
bin\openocd.exe -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg
response
Info : auto-selecting first available session transport "swd". To override use '
transport select <transport>'.
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Error: Could not find MEM-AP to control the core
Info : Listening on port 3333 for gdb connections
Open telnet program eg teraTerm and connect to localhost on port 4444, i.e. 127.0.0.1 telnet port 4444
cmd window shows
Info : accepting 'telnet' connection on tcp/4444
in telnet (i.e. teraTerm) type
nrf52.dap apreg 1 0x04
returns 0 <<< chip protected
then
nrf52.dap apreg 1 0x04 0x01
then
nrf52.dap apreg 1 0x04
returns 1 << chip un-protected
then power cycle board
Can now use arduino ide to flash softdevice and code low power BLE
Even though the dap command is listed by openOCD help, it isn't implemented for transport hla_swd that you have to use with ST-Link.
If the ST-Link is a generic type from China, it can be upgraded to CMSIS-DAP which uses the swd transport and supports the nrf52.dap apreg 1 0x04 0x01 command to disable the readback protection and erase the flash. You'll need another ST-Link to do that, or you can instead install CMSIS-DAP on a generic STM32F103C8T6 board.
After that you can either use ST-Link to program the nRF52 or continue using CMSIS-DAP, which can also be used to program STM32 MCU.
Nucleo board embedded ST-Links can also be upgraded to J-Link, which allow the use of the "recover" option in nRFgo Studio to erase the flash, it should also work with "nrfjtool --recover" or OpenOCD.
If anyone encounters this problem, I solved the problem by getting an original Jlink-Edu. I also had to pull the reset pin of the microcontroller high to get the jlink working.
There are lots of JTAG messages.
I think you might be missing the
transport select hla_swd
line in your (board) cfg file. The NRF5x chips only work properly with SWD, and ST-Link uses the hla_swd variant.

TCP SYN sent with Scapy never received by server nor noticed by Wireshark on the loopback interface

I have a problem with a very basic usage of Scapy on Windows 7 (Python 3.6, Scapy 2.4.0). I'm also running Npcap 0.99r7 and Wireshark 2.6.2 on this sytem. The system does only have one wireless network interface plus the Npcap loopback interface.
I set up this very classic TCP server... :
import socket
host = '127.0.0.1'
port = 8089
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(1)
connection, address = s.accept()
while 1:
try :
data = connection.recv(1024)
except ConnectionAbortedError:
break
if data:
print('Received: %s' % (data.decode ('utf-8')))
connection.sendall('Data received'.encode())
connection.close()
s.close()
...and I set up this very classic TCP client:
import socket
host = '127.0.0.1'
port = 8089
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send('Hello, world!'.encode())
data = s.recv(1024)
print('Received: %s' % (data.decode('utf-8')))
s.close()
Both works fine. Wireshark does report the whole TCP traffic on the loopback interface.
Now, I'm running the server, and I try to run that piece of code that would just send a SYN to the server with Scapy :
from scapy.layers.inet import IP
from scapy.layers.inet import TCP
from scapy.sendrecv import *
dstHost='127.0.0.1'
dstPort = 8089
packet = IP(src='127.0.0.1', dst=dstHost)/TCP(dport=dstPort, flags='S')
response=sr1(packet, timeout=10)
response.display()
Python reports :
Begin emission:
..Finished sending 1 packets.
......Traceback (most recent call last):
File "R:/Documents/Projets/python/hacking/scan.py", line 46, in <module>
response.display()
AttributeError: 'NoneType' object has no attribute 'display'
Received 8 packets, got 0 answers, remaining 1 packets
Moreover, Wireshark does not see anything on the loopback interface. May somebody give an hint ?
Update 1
As suggested, I tried a more explicit code using sendp() and not send(), since we are talking layer 2 here:
route_add_loopback()
packet = Loopback()/IP(src='127.0.0.1', dst='127.0.0.1')/TCP(dport=8089, flags='S')
sendp(packet,iface='Npcap Loopback Adapter')
Unfortunately, Wireshark does not sniff the packet on either interfaces (the 'Intel(R) Centrino(R) Advanced-N 6235' and the 'Npcap Loopback Adapter').
Note that the call to route_add_loopback() is required, or show_interfaces() won't report the 'Npcap Loopback Adapter', which means that sendp() will fail. It is possible to restore the Scapy routing table by calling conf.route.resync () after route_add_loopback(), but the result is the same : Wireshark does not sniff the packet on either interface.
Should somebody find some Python piece of code running on Windows 7 that succesfully sends a simple TCP packet on the 'Npcap Loopback Adapter', he would be welcome...
The loopback interface is not a "regular" interface; this is particularly true for Windows.
You can check the route used by Scapy to send the packet by running: packet.route().
If the route displayed does not use the loopback interface, you can try to run (that's windows specific) route_add_loopback() and try again.
Another option would be to use srp1() instead of sr1(), and specify the loopback interface as iface= parameter.

How to get the ESP8266 to work in update mode?

I have been trying to get my WiFi module, ESP8266 to work in the "update mode" where you connect GPIO_0 to ground.
The board is functional when GPIO_0 is disconnected from ground and I am able to use AT commands to talk to it via the Arduino serial monitor.
Following is what it prints upon connecting:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x40100000, len 1396, room 16
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4
tail 8
chksum 0xc0
csum 0xc0
2nd boot version : 1.4(b1)
SPI Speed : 40MHz
SPI Mode : DIO
SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 # 1000
rrlÌÿ
Ai-Thinker Technology Co.,Ltd.
ready
However, I cannot do most things as the firmware is out of date.
As a result, I am trying to update it (with no success)
When I set it to update mode and use the python tool "esptool.py", the script fails to connect to the ESP board.
Following is the command:
python esptool.py -p /dev/ttyUSB0 write_flash 0x00000 "/home/aditya/Desktop/v0.9.2.2 AT Firmware.bin"
Following is the output:
Connecting...
Traceback (most recent call last):
File "esptool.py", line 532, in <module>
esp.connect()
File "esptool.py", line 159, in connect
raise Exception('Failed to connect')
Exception: Failed to connect
I have even run the Windows counterpart of this tool "ESP Flasher" with no luck
The one who helps will be given a cookie (unless you value privacy)
This tool (esptool.py) works with a ROM bootloader, which is only started if GPIO_0 is tied to the GND during hardware reset. Bootloader also times out pretty fast, so just connecting GPIO_0 to the ground is not enough.
For me, following works:
Connect TXD/RXD/GND/VCC to the PC and CH_PD to VCC;
Make sure I can talk to the firmware via terminal (picocom/minicom/etc);
Connect GPIO_0 to the GND;
Connect RST to GND;
Release RST;
Run esptool.py
If still no dice, swap 5 and 6 above, i.e. first run esptool.py, then (as quickly as possible) release/disconnect RST. You will only have a second or two before esptool.py times out.
Try making the ground of all devices connected: if you have a level shifter inbetween, make sure the GND is tied to the GND of Arduino and also to the RS232 GND.

em1: Watchdog timeout -- resetting - freebsd 8.3 / network down

i have a major issue that i can't find nor heads nor tails of. I have googled this error, but i have not found any relevant solutions.
The problem:
I have about 8 servers, all running freebsd 8.3 p3 / p4. This fileserver is pushing around 300-400 mb/s.
This is the second time it happens. The network card just seems to die. I have 2 network cards in it, and i can reach the server via private network, and it all works okay, only that the public network is completely down. I have tried restarting the network interfaces: /etc/rc.d/netif restart && service routing restart | ifconfig em1 down && ifconfig em1 up, but with no success.
I can only bring the connectivity back if i reboot the server.
Below is the output from dmesg.boot that shows the network card drivers info.
em0: <Intel(R) PRO/1000 Network Connection 7.3.2> port 0xf020-0xf03f mem 0xf7b00000-0xf7b1ffff,0xf7b25000-0xf7b25fff irq 20 at device 25.0 on pci0
em0: Using an MSI interrupt
em0: [FILTER]
em0: Ethernet address: 00:25:90:7a:8e:9f
ehci0: <EHCI (generic) USB 2.0 controller> mem 0xf7b24000-0xf7b243ff irq 16 at device 26.0 on pci0
em1: <Intel(R) PRO/1000 Network Connection 7.3.2> port 0xd000-0xd01f mem 0xf7900000-0xf791ffff,0xf7920000-0xf7923fff irq 16 at device 0.0 on pci3
em1: Using MSIX interrupts with 3 vectors
em1: [ITHREAD]
em1: [ITHREAD]
em1: [ITHREAD]
em1: Ethernet address: 00:25:90:7a:8e:9e
----------------------------
pciconf -lv
em1#pci0:3:0:0: class=0x020000 card=0x000015d9 chip=0x10d38086 rev=0x00 hdr=0x00
vendor = 'Intel Corporation'
device = 'Intel 82574L Gigabit Ethernet Controller (82574L)'
class = network
subclass = ethernet
em0#pci0:0:25:0: class=0x020000 card=0x150215d9 chip=0x15028086 rev=0x05 hdr=0x00
vendor = 'Intel Corporation'
class = network
subclass = ethernet
I would really love some help to debug and fix this, because it usually happens while i am sleeping, at random days, and it's driving me crazy. I love my sleep.
This is a supermicro server, right?
cat /var/run/dmesg.boot | grep MSI
em0: Using an MSI interrupt
em1: Using MSIX interrupts with 3 vectors
Your answer is probably here: http://forums.freebsd.org/showthread.php?t=27736

How do I bridge two physical serial ports to each other in software (and log the data going across)?

Basically, I want to put my computer in the middle of a serial line and record the conversation going across it. I'm trying to reverse engineer this conversation and eventually emulate one end of the conversation.
Rough Diagram of what I'm trying to do:
Normally, I have this:
__________ __________
| | | |
|Device 1|<======>|Device 2|
|________| |________|
I want to do this:
__________ __________ __________
| | | | | |
|Device 1|<===>|Computer|<===>|Device 2|
|________| |________| |________|
With the computer in the middle basically bridging the connection between the two devices and logging the data that goes across.
Answers using any programming language are probably useful. Preferably I would be able to do this on either Windows or Linux (or both if someone has a general solution to this problem).
Well, a programmatic way to do it would be to just open the relevant devices, and start forwarding data between them, simultaneously saving to a file.
Most any language can do it. There are nice libraries for things like java and python.
Several implementations exist on the web, I found a python one called Telnet Serial Bridge (TSB) by googling, which would allow you to bridge connections together over ethernet, and log using telnet tools like putty.
Though in the past, I've used the java rxtx serial comm library from rxtx.qbang.org to do it myself, though I suspect there's an updated version now, or maybe something built into the JVM proper.
Adapted from an example on that site:
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class TwoWaySerialComm
{
void bridge( String portName1, String portName2 ) throws Exception
{
CommPortIdentifier portIdentifier1 = CommPortIdentifier.getPortIdentifier(portName1);
CommPortIdentifier portIdentifier2 = CommPortIdentifier.getPortIdentifier(portName2);
if ( portIdentifier1.isCurrentlyOwned() || portIdentifier2.isCurrentlyOwned())
{
System.out.println("Error: Port is currently in use");
}
else
{
CommPort commPort1 = portIdentifier1.open(this.getClass().getName(),2000);
CommPort commPort2 = portIdentifier2.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort && commPort2 instanceof SerialPort )
{
SerialPort serialPort1 = (SerialPort) commPort1;
serialPort1.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in1 = serialPort1.getInputStream();
OutputStream out1 = serialPort1.getOutputStream();
SerialPort serialPort2 = (SerialPort) commPort2;
serialPort2.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
InputStream in2 = serialPort2.getInputStream();
OutputStream out2 = serialPort2.getOutputStream();
(new Thread(new SerialReader(in1, out2))).start();
(new Thread(new SerialReader(in2, out1))).start();
}
else
{
System.out.println("Error: Only serial ports are handled by this example.");
}
}
}
/** */
public static class SerialReaderWriter implements Runnable
{
InputStream in;
OutputStream out;
public SerialReader ( InputStream in, OutputStream out )
{
this.in = in;
this.out = out;
}
public void run ()
{
byte[] buffer = new byte[1024];
int len = -1;
try
{
while ( ( len = this.in.read(buffer)) > -1 )
{
out.write(buffer,0, len);
System.out.print(new String(buffer,0,len));
}
}
catch ( IOException e )
{
e.printStackTrace();
}
}
}
public static void main ( String[] args )
{
try
{
(new TwoWaySerialComm()).bridge("COM1", "COM3");
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
This is a small python script to bridge between two physical ports` #!/usr/bin/python
import time, sys, serial
import collections
import re
from serial import SerialException
from termcolor import colored
SERIALPORT1 = "/dev/rfcomm0" # the default com/serial port the receiver is connected to
BAUDRATE1 = 115200 # default baud rate we talk to Moteino
SERIALPORT2 = "/dev/ttyUSB0" # the default com/serial port the receiver is connected to
BAUDRATE2 = 9600 # default baud rate we talk to Moteino
# MAIN()
if __name__ == "__main__":
try:
# open up the FTDI serial port to get data transmitted to Moteino
ser1 = serial.Serial(SERIALPORT1, BAUDRATE1, timeout=1) #timeout=0 means nonblocking
ser1.flushInput();
print "\nCOM Port [", SERIALPORT1, "] found \n"
except (IOError, SerialException) as e:
print "\nCOM Port [", SERIALPORT1, "] not found, exiting...\n"
exit(1)
try:
# open up the FTDI serial port to get data transmitted to Moteino
ser2 = serial.Serial(SERIALPORT2, BAUDRATE2, timeout=1) #timeout=0 means nonblocking
ser2.flushInput();
print "\nCOM Port [", SERIALPORT2, "] found \n"
except (IOError, SerialException) as e:
print "\nCOM Port [", SERIALPORT2, "] not found, exiting...\n"
exit(1)
try:
while 1:
ser1_waiting = ser1.inWaiting()
if ser1_waiting > 0:
#rx1 = ser1.read(ser1_waiting)
rx1 = ser1.readline()
ser2.write(rx1)
print colored(rx1, 'red')
ser2_waiting = ser2.inWaiting()
if ser2_waiting > 0:
#rx2 = ser2.read(ser2_waiting)
rx2 = ser2.readline()
ser1.write(rx2)
print rx2
except IOError:
print "Some IO Error found, exiting..." `
I can offer a solution for Windows using 2 software utilities:
TCP COM Bridge - can connect 2 COM port over internal TCP connection.
Advanced Serial Port Monitor - can monitor and record the conversation between devices.
Both utilities are here:
http://www.aggsoft.com/
Well, I'm a novice and since you didn't say anything about the platform you’re on, I'll tell you what I did, but I'll warn you in advance, this depends on software you may or may not have and this may not actually be an answer at all, so caveat lector.
My hardware is a MacBook Pro 2.4 GHZ running 10.7.5 with 4GB ram.
What I was trying to do was read the serial comm chatter from an application that was running in Wine (since the application was windows based, but I didn’t want to use windows (icky poo). Heck , I didn’t want to use mac either, but I wasn’t making the headway I wanted to in virtual linux either, add to that Ubuntu is a little weird in the direction they’ve taken with some of the nitty gritty command-line “schtuff”.
Required software to start.
Parallels Desktop Build 7.0.15107 (Might be able to do this in Virtual Box, I haven't tried)
MultiCom (Freeware By Martin Louis for Mac)
http://members.iinet.net.au/~mgl/MartysPlace/MultiCom.html
Ubuntu 8.0.4 Hardy Heron
There maybe other ways, I must have chased down about a dozen ways to do what I wanted to do and I'm not happy yet with the output so this maybe a huge waste of time.
This solution doesn't use
strace
ttysnoop
gpspipe
socat
pyserial
And to be honest, ttysnoop seemed to be exactly what I wanted, socat seemed like a distant 2nd but a little too much for a novice imo.
The problems I ran into with other clients (possibly due to my inability to figure out how to change features about com connections) had to do with blocking. What you want, when you monitor a serial port, is a non-blocking connection. So you just listen to the port chatter and don’t interfere.
If you make a connection to it with clients like...
jpnevulator
minicom
cutecom
screen, etc.
...it seems that they take over the com port and the serial port is suddenly not available for you to monitor. There must be a way to configure them so this isn’t the case but I couldn’t figure it out. Add to that the complication that if you try to monitor from the mac side what the ports in your virtual machine are doing, it’s a little stickier still or trying to use any way you can to get past this “bump” of how to send the same data to 2 serial ports. So if you're smarter than me, I invite you to please make me less dumb.
On the Mac Side…
Launch MultiCom
Set – Port A
a) Configure as a Serial
b) Serial Device /dev/cu.KeySerial (in my case, you’ll need to discover what port you need heuristically using Terminal and typing ls /dev/tty.*
c) Click “Ok” and select the enable check box.
Set – Port B
a) Socket File Server
b) Socket File : /Users/shadowwraith/Desktop/socket.txt
On Virtual Machine Side (Parallels Ubuntu 8.0.4)
a) With the VM shutdown configure add 2 serial ports that reference the same socket file as CLIENTS (not servers) by specifying the full path.
b) Enable both by selecting the check box (Note: remember as far as the VM is concerned there is no USB connection to the serial device. You’re making that connection via the MultiCom software (or someother means if you know of one, what MultiCom is doing is acting as a conduit for the single port connection to the USB serial connector then duplicating all I/O to the socket file server which all the clients can connect to which can be multiple VMs or multiple serial ports in the same VM.)
c) Boot VM and set one serial port for your program and the other serial port for your sniffing. And POOF..there you go.
See below for more technical minutia about what to do...
Linux
How to display a serial port?
dmesg | grep tty
This is what you would type in to get the sniffer to read the input assuming the serial port you chose to actively use a serial connection was on the other socketed port, ttyS0 at com 1 for instance (ttyS1 is at com 3 in this but you can figure this out by using dmesg | grep tty).
Seeing the information…
jpnevulator --ascii --timing-print --tty "/dev/ttyS1" –read
Unrelated information that you shouldn’t use, but lead-up to me understanding why it was the wrong way to do this…
How to map a com port in linux (when you’re not worried about sniffing a port or using configure to add the serial ports)?
ln -s /dev/ttyUSB0 com3
To undo this type
unlink com3
Where ttyUSB0 is the port found from dmesg | grp tty and com3 is the desired port for Wine. This is done in the ~/.wine/dosdevices directory.
For example take a cable from rx/tx of devices to the computer com port rx pin and run a terminal or serial port logger. Just that.

Resources