Help with Fez Panda II

I’ve just started to use a Fez Panda II, and have two 9 pin serial ports connected to my fez (COM1 and COM3). I was looking/wanting to add another (COM4), with the ability of sending/receiving data from COM1 to (primarily) COM3 through my Panda. However, to do this I would obviously have to replicate the data coming in from COM1 and map it to COM3.

My question is: How do i replicate COM1’s data and send it through to COM3?



Is there any way of achieving this?

Sorry if I am posting in the wrong forum, it's just this is the first Panda project i'm doing!

PS. If possible, I have a switch in Di20 in which it would be great if I could switch between COM3 and COM4 from it using:


```cs
MySwitch.Read()==true
{
//use COM3
}
else
{
//use COM4
}

Any help/ advice much appreciated!

hi there jbutler483, welcome to the forum.

Serial is quite reasonable. Shouldn’t be too hard, except if you have high speed data and if you’re trying to do tricky things with the received data.

Your serial “redirector” can be pretty easily achieved. Using the DataReceived() event handler, you can simply receive the character/s on the serial port buffer, and write them to the alternate output port.

There are a couple of ways to approach your “optionally choose COM3 or COM4” that might be reasonably simple, some that are a little easier on processing and others not so. Put simply, to do the maximum throughput you want to do the minimum processing in the event handler above, so putting a conditional “if switch set, send to COM4 not COM3” can actually add some overhead that may have a big effect. So easy scenario is to have two event handlers, one that writes to COM3 and one to COM4, and at program start up time detect the switch position and based on that, wire in the correct handler. The more impactful way would be to use a construct like you have shown on the switch and evaluate it every time through the handler.

Good luck, sounds an interesting project!

Thanks Brett! I have to say I didn’t think of doing it that way but makes it seem a whole lot easier than the way I was thinking! I like your idea of the single eventHandler, but looks to me (as there will be quite a lot of traffic) the best way would be to use the two handler approach!

Thanks again.

1 Like