A Ham Radio to here!.
My protocol it's easy, to any string incomming for some port, add a number in the begining to tell to the PC what is the channel who is sending data.
For send data from PC to serial the same idea, include one char like header to mux the port and let the data to that port. Of course this char must be erased in the Mega.
My B plan is use 4 Mega8, one like master and the others like slaves, polling them via SPI, and using the same logic to switch the port/to know what's the incomming port. Other idea is use some I/O to tell to master device who of this Mega8 have data, similar to a INT3,4 from PC.
But i realy want to use only one device, to keep my board small, i'm gonna to test this using Arduino software's serial ports, i must read all the inputs pins on the same loop, and adjust the delays, RAM this device have a lot so buffer of 128 bits can be handled.
The problem with software is what happends when two devices are sending data, this devices only have Rx and Tx, i don't have RTS so i can't tell to the device Wait! to send data.
Other idea is use a 16625 from PC, but i don't want to use specifics IC because them are hard to buy here in my country.
I have build one of this, but this is a switch, if the device must be pooled is great because i switch the port, i have one working with for serials, i use the DTR and RTS to switch them, and works Great!.
But now the idea is build a real port and not a switch! :o
For Rs-232 write/read in PC i always use the MSCOMM from VB6, in fact i have writed a Class in VB who hide the Mscomm.lib and keep private for all the software, i can write a DLL who expose only the functions i need, looks like a DLL with protocol inside, and it open/close the port, set speed and pharse the data/binary etc. Similar to a driver.