Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

CAT via .NET SerialPort class

Member ✭✭
edited January 2024 in SmartSDR API

I am 99% there with a voice keyer app I'm experimenting with. I am having a problem getting the signal correct to CAT via a SerialPort.

I have a TX CAT configured for COM5 and I can connect to it just fine.

I have it set to respond to RTS with Polarity = Active Low

My app is configurable for RTS/DCS and Active Low/HI but Low/Hi seems backwards.

It boils down to this:

m_SerialPort.RtsEnable = true

keys the radio! I thought if Polarity = Active Low, setting RtsEnable to FALSE would key the radio??

Sure enough, if I change the CAT to be Active High, then

m_SerialPort.RtsEnable = false

keys the radio!

Where have I messed this up?

Thanks, and 73!

-Brian n8wrl

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Member ✭✭

    I sent an email to devhelp with more details:


    Good morning!

    I am writing a voice keyer to get familiar with CAT programming on the Flex, and I'm 99% there. My last problem is actually triggering PTT.

    I have a PTT CAT port set up configured for DTR Active High, (see attached screenshot) although I can reproduce “the problem” with all the other combinations of RTS/DTR Active Low/High.

    I can connect to the port using a .NET SerialPort object with no trouble.

    Here is likely the basis of my confusion - I think “Active High” means setting the port to “High” or “True” will enable PTT, but it seems just the opposite. Here is some very simple .NET8 code to demonstrate:

    using System.IO.Ports;

    Console.WriteLine("Creating SerialPort");

    using (SerialPort port = new("COM5"))

    {

      port.Open();

      Console.WriteLine($"Port Open RTS={port.RtsEnable} DTR={port.DtrEnable}");

      // Flex CAT set to DTR Active HI

      // So this should key the radio BUT IT DOES NOT!

      port.DtrEnable = true;

      Console.WriteLine($"PTT ON RTS={port.RtsEnable} DTR={port.DtrEnable}");

      Console.ReadKey();

      // And this should unkey it BUT THE RADIO GOES INTO TRANSMIT!

      port.DtrEnable = false;

      Console.WriteLine($"PTT OFF RTS={port.RtsEnable} DTR={port.DtrEnable}");

      Console.ReadKey();

      port.Close();

    }

     

    The output is:

    Creating SerialPort

    Port Open RTS=False DTR=False

    PTT ON RTS=False DTR=True      ←- RADIO IS NOT KEYED

    PTT OFF RTS=False DTR=False    ←-- RADIO IS KEYED!!

     

    Note that even after the program closes the radio stays keyed and I have to shut down SmartSDR to get it to unkey.

    So it seems that my understanding of “Active High” is backwards - a port set to “Active High” should be set to LOW/False to key the radio and vice-versa.

    Does this make any sense?

    Thank you, and 73!

    -Brian n8wrl

  • Member, Super Elmer Moderator

    Hi Brian, so by switching the on and off sense of the RTS line, everything works?

  • Member ✭✭

    Hi Len!

    Switching on/off of RTS affects PTT but not the way I would expect.

    When I set up PTT CAT with the RTS line and "Active High" setting RTS to FALSE turns on PTT.

    It's backwards - Active High needs FALSE while Active Low needs TRUE.

    I gotta believe it's just my misunderstanding. So much software is already in use. I must be doing something wrong.

    73

    -Brian n8wrl

  • Member, Super Elmer Moderator

    Well, I guess it depends on the definition of true and false as implemented with respect to high and low signals. If you flip the true/false sense and it works, then it is probably just your understanding.

    I seem to remember something about RS232 signals being negative voltages, and if so, that would flip the sense. Been a looong time since I ever fooled with the physical layer of RS232, so I may not have that right.

    In any event, as long as it works (flipped), I don't think that you are doing anything wrong.

  • Member ✭✭✭

    It seems correct to me.

    If you select Active Low and True, the RTS line will go low which is what the PTT line needs to key.

  • Member ✭✭

    Well, this has been quite a ride.

    First off, you guys are correct, "Active LO" means setting the port to TRUE triggers PTT. Hopefully you can forgive me, because I'm a software guy, and, to me "LO" means "FALSE." (I also don't understand the age-old convention that a switch is "open" if current doesn't flow, while a "closed" switch will. On a server, a port is "open" if traffic flows and closed otherwise.)

    I just have to get used to the nomenclature.

    This led me down another rabbit hole - Polarity Active HI is unusable from the Microsoft .NET SerialPort object. I spent quite a bit of time spelunking the source code and learned that it wants to manage the DTR and RTS ports. When I close the serial port, it asserts DTR and RTS to false which, when polarity is HI, triggers PTT! When Polarity=LO, all is well.

    So, I can either restrict CAT PTT ports to be Polarity=LO or connect to a "CAT" port and send TX0/TX1. Need to find out how portable that is across radio brands - Looks like Yaesu uses that too.

    73 all, and thanks again!

    -Brian n8wrl

  • Administrator, FlexRadio Employee, Community Manager, Super Elmer, Moderator admin

    SMOP = Simple Matter of Programming

    As you know, it is never that simple.

    Glad to see you playing with it.

    73

  • Member ✭✭

    Hey Mike!

    Do you know of anyone using Polarity=HI? If so, what are they using to talk to the serial port?

  • Administrator, FlexRadio Employee, Community Manager, Super Elmer, Moderator admin

    I do not. But, I am sure some of the Microwave guys would use it for PreAmps, etc.

Leave a Comment