I found this code for a simple chat that uses serial ports to communicate, and I wanted to see it work. I googled for a while and found com0com to simulate the RS-232 connection as I don't have a cable, but now I'm stumped and have no idea how to actually make this work
The code (in python):
from serial import *
from threading import Thread
class Receiver(Thread):
def __init__(self, serialPort):
Thread.__init__(self)
self.serialPort = serialPort
def run(self):
text = ""
while (text != "exit\n"):
text = serialPort.readline()
print ("\n machine1: " + text)
self.serialPort.close()
class Sender(Thread):
def __init__(self, serialPort):
Thread.__init__(self)
self.serialPort = serialPort
def run(self):
text = ""
while(text != "exit\n"):
text = raw_input("Type your message>>") + "\n"
self.serialPort.write(text)
self.serialPort.close()
serialPort = Serial("\\\\.\\CNCA0")
send = Sender(serialPort)
receive = Receiver(serialPort)
send.start()
receive.start()
Thanks in advance.