Using a named pipe to simulate a serial port on a VMware virtual machine (linux host and client)
Posted
by
Dave M
on Super User
See other posts from Super User
or by Dave M
Published on 2012-09-23T04:17:30Z
Indexed on
2012/09/23
21:40 UTC
Read the original article
Hit count: 306
Trying to write a python program to create a simulated data stream and feed it, through a named pipe, to a VMware virtual machine. The host is running Ubuntu 11.10 and VMware player 5.0.0. The Vm is running Ubuntu netbook 10.04. I am able to get the pipe working on the local machine but I am not able to get the pipe to pass data through the virtual serial port to the programs running on the virtual machine.
#!/usr/bin/python
import os
#
# Create a named pipe that will be used as the serial port on a VMware virtual machine
SerialPipe = '/tmp/gpsd2NMEA'
try:
os.unlink(SerialPipe)
except:
pass
os.mkfifo(SerialPipe)
#
# Open the named pipe
NMEApipe = os.open(SerialPipe, os.O_RDWR|os.O_NONBLOCK)
#
# Write a string to the named pipe
NMEAtime = "235959"
os.write(NMEApipe, str( '%s\n' % NMEAtime ))
- Test to see if the python program is working on the host machine (displays 235959 if data is passing through the pipe)
$ cat /tmp/gpsd2NMEA
235959
- Serial port as defined in the VMware .vmx file:
serial0.present = "TRUE"
serial0.startConnected = "TRUE"
serial0.fileType = "pipe"
serial0.fileName = "/tmp/gpsd2NMEA"
serial0.pipe.endPoint = "client"
serial0.autodetect = "FALSE"
serial0.tryNoRxLoss = "TRUE"
serial0.yieldOnMsrRead = "TRUE"
- Test to see if the serial port in the VM is receiving data
$ cat /dev/ttyS0
or
$ minicom -D /dev/ttyS0
or
$ stty -F /dev/ttyS0 cs8 -parenb -cstopb 115200
$ echo < /dev/ttyS0
- None of these display any data from the python program.
© Super User or respective owner