# How to add a SCPI Serial instrument

**URL:** <https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316>\
**Category:** General\
**Tags:** instruments\
**Created:** [December 5, 2023, 3:20pm UTC](https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316 "2023-12-05T15:20:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesse123](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jesse123](https://forum.opentap.io/u/jesse123)\
**Post date:** [December 5, 2023, 3:20pm UTC](https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316/1 "2023-12-05T15:20:38Z")

</div>

Hello,  
I want to add a SCPI Serial instrument, because the default ScpiInstrument can’t set the baudrate and so on, but when i wait to add this SCPI Serial instrument, i can’t access the Visa class, so i don’t how to do, could you pls help me?  
Thanks.

---

<div class="post-metadata">

**Author:** ![alan\_copeland](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@alan\_copeland](https://forum.opentap.io/u/alan_copeland)\
**Post date:** [December 5, 2023, 4:21pm UTC](https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316/2 "2023-12-05T16:21:08Z")

</div>

Hello @jesse123!

I did something similar a while back. You need to create your own class and implement the IScpiIO2 interface. Then, you can pass your IScpiIO2 implementation to the the ScpiInstrument constructor.

A quick way to implement your IScpiIO2 interface, would be to copy the default ScpiIO implementation here: [https://github.com/opentap/opentap/blob/a09f3c1ab9265af52149bb7153a844394e584783/Engine/ScpiIO.cs#L9](https://github.com/opentap/opentap/blob/a09f3c1ab9265af52149bb7153a844394e584783/Engine/ScpiIO.cs#L9)

You can see that there is an OpenTap.Visa class referenced by the default ScpiIO implementation. With that you can call any method/attribute get/set in VISA library. Create a custom Property that you expose through your instrument plugin (baudrate/flow control/etc…), and you should be able to accomplish what you want.

---

<div class="post-metadata">

**Author:** ![jesse123](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jesse123](https://forum.opentap.io/u/jesse123)\
**Post date:** [December 6, 2023, 10:25am UTC](https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316/3 "2023-12-06T10:25:34Z")

</div>

Hello @alan_copeland  
Thanks for your asnwer, but the Visa access permission is internal, so the interface implement base on the IScpiIO2 is not allow as a plugins, it’s than right?

---

<div class="post-metadata">

**Author:** ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)\
**Post date:** [December 7, 2023, 5:46am UTC](https://forum.opentap.io/t/how-to-add-a-scpi-serial-instrument/1316/4 "2023-12-07T05:46:36Z")

</div>

You can set the IScpiIO used in the constructor like this:

```cs
        public class MyScpiInstrument : ScpiInstrument
        {
            public MyScpiInstrument() : base(new MyScpiIo())
            {
                IO.SRQ += sender => Log.Debug("SRQ"); // unused.
            }
            
            public MyScpiIO IO => ((IScpiInstrument)this).IO as MyScpiIO;
        }
        

```
