Reputation: 11
I have a program that splits a serial device into multiple virtual serial ports and routes all the data to them.
---- /dev/ttyS1.a [data]->
|
[data]-> /dev/ttyS1 ---- /dev/ttyS1.b [data]->
|
---- /dev/ttyS1.c [data]->
My working program (pseudo code for sake of readability and simplicity):
poll(...) {
// Route data from master to vsp
master.read(buf)
for(virtual serial ports as vsp) {
vsp.write(buf)
}
// Route data from vsp to master (if need be)
for(virtual serial ports as vsp) {
if(vsp.needs_to_write()) {
vsp.read(buf)
master.write(buf)
}
}
}
I have one physical serial port device on my machine that continuously feeds data through, which is how I tested if my program initially works, but I would like to write a test to emulate/simulate writing and reading both directions and verifying the data on both ends. Since the data I am receiving from my physical serial port device writes seemingly random data it is hard to verify what is going in is exactly what is being written.
How would I be able to do this? (pseudo code)
1. fork process that feeds a known char sequence into /dev/ttyS2 in a loop
2. use my program to read from the COM `master.read(buf)` and then write to the vsp `vsp.write(buf)`
3. how can I verify that after writing to the buf that the vsp has the correct data?
Any help is appreciated I am confused on how to automate testing this.
Edit 1: No one can help?
Upvotes: 1
Views: 1097
Reputation: 39
I think you can use com0com to test. You can connect virtual serial ports and then write to one and read from other what it received. enter link description here
Upvotes: 0