Thursday, November 20, 2014

VirtualBox virtual serial port Windows Guest to linux host.


1.) Select "Enable Serial Port"
2.) Port mode: Host Pipe
3.) Create Pipe Checked.
4.) Port/File Path: /tmp/vboxCOM'

Now the port shows up windows.

My version of netcat allows connecting to sockets.

extra/gnu-netcat 0.7.1-5 [installed]



nc -U /tmp/vboxCOM
test
testback


To test sending data over the socket with bash:

function sendData()
{
    nc -U /tmp/vboxCOM <<< $(echo -en "\x1B$*\xD")
}
echo "Sending ST"
sendData "ST"

With python
#!/usr/bin/env python
import socket
import os, os.path
import time 
socketLocation = '/tmp/vboxCOM' 

print("Connecting...")
s = socket.socket(socket.AF_UNIX)
s.settimeout(1) # 1 second timeout, after all it should be instant because its local
s.connect(socketLocation)

def sendMessage(message):
    '''
    Sends a message to a socket.
    '''

    s.send(str.encode(message))
 
 
print("Sending a test message")
sendMessage("test\n")

No comments:

Post a Comment