I am complete serial communication novice but I have been tasked to connect to an external system using serial connection so I can query the system for some data. I am doing this in Xamarin.Forms
At runtime, I need to decide whether to connect to an external system hosted in the cloud or to a system connected through serial (IP/Port) connection (hosted in house).
My initial thought to approach this is to have some kind of factory pattern determining at run time if there is an active serial connection at the port that is designated to connect to the in-house system. If so, open it and use it to talk to the in-house system; otherwise, attempt to connect to the system hosted in the cloud.
Now to my question which is probably very basic...
- Is there a way to check if a port is being used?
- Basically, if there is an active connection to it?
- Or does this question even make any sense and my approach above is wrong and there is a better way or no way to do this?
From my very initial reading, it looks like there is no way to do this. All I am seeing is instruction to see if port is in use (if connection is already open).
UPDATE
To clarify, the device might be an iPad, Android tablet, or Windows UWP tablet and it is connected to a docking station through USB and docking station is connected through network cable to an external system.