# Best approach and methods for serial communication (Python)

**URL:** <https://forum.opentap.io/t/best-approach-and-methods-for-serial-communication-python/2033>\
**Category:** General\
**Tags:** python, plugin, instruments\
**Created:** [June 26, 2024, 2:14pm UTC](https://forum.opentap.io/t/best-approach-and-methods-for-serial-communication-python/2033 "2024-06-26T14:14:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jb111](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jb111](https://forum.opentap.io/u/jb111)\
**Post date:** [June 26, 2024, 2:14pm UTC](https://forum.opentap.io/t/best-approach-and-methods-for-serial-communication-python/2033/1 "2024-06-26T14:14:17Z")

</div>

Hi,  
I am currently trying to create a simple instrument which opens a Serial connection to a specific COM port and baudrate. I am currently attempting to open the connection using PySerial, but I suspect it is not the best approach for OpenTap development.

Is there a way to do this with the “built-in” .Net/C# package interfaces?

If not, then let’s say I have a ComPort `property(String, "COM3")` from which I want to extract the value to enable in a  
`ser = serial.Serial() `  
connection as  
`ser.port = *extract*(ComPort)`  
Would there be a way to do this?

I am developing the Instrument in Python.

Any help is much appreciated!

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [June 26, 2024, 8:50pm UTC](https://forum.opentap.io/t/best-approach-and-methods-for-serial-communication-python/2033/2 "2024-06-26T20:50:24Z")

</div>

.NET supports serial ports. Here’s some pseudocode:

```csharp
using System.IO.Ports;

var port = new SerialPort();

// here you should set the port's properties, like PortName, BaudRate, Parity, DataBits, StopBits, Handshake, ReadTimeout, WriteTimeout, etc.

port.Open();

port.Write("some command");

```

---

<div class="post-metadata">

**Author:** ![mschmidt](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mschmidt](https://forum.opentap.io/u/mschmidt)\
**Post date:** [August 22, 2024, 12:46pm UTC](https://forum.opentap.io/t/best-approach-and-methods-for-serial-communication-python/2033/3 "2024-08-22T12:46:36Z")

</div>

> [@david-wsd](#):
>
> `s`

I am using this approach but having issue setting the Handshake. As its a type and not sure how to typecast.

Br.  
Martin
