poll() and USB-serial adaptors

On a sunny day (Sat, 2 Jun 2018 20:41:13 +0000 (UTC)) it happened Martin Gregorie wrote in :

If all else fails, you could buy a MAX232 chip (about 2 UKP / 3 Euro IIRC), and build you own logic level to RS232 interface. You will need 3 1uF/16V electrolytic capacitors too:

formatting link
Your logic level 3.5 mm plug tx goes to pin 11, and comes out as real RS232 TXD on pin 14 to the D connector. The real RS232 RXD from the D connector comes in on pin 13, and goes to your 3.5mm connector's rx. 'n.c' stands for 'not connected' pin.

The MAX 232 has a build in voltage converter that creates about +10V and -10V for the correct output swing. Be careful buying MAX232 from ebay, I got a bunch of bad ones from there. The ones I got from conrad are OK.

Reply to
Jan Panteltje
Loading thread data ...

On a sunny day (Sun, 03 Jun 2018 07:07:24 GMT) it happened Jan Panteltje wrote in :

Should read: and goes from pin 12 to your 3.5mm connector's rx.

Reply to
Jan Panteltje

I don't have that many pins :-)

Made up a cable: D9-> 3.5 stereo jack cable with handshake jumpers (7-8,

1-4-6) today and tested it on my old pFranc USB->RS232 adapter using my termination/test box to monitor signal levels. It worked as expected when driven by ptlrc on both RPi and Lenovo T440 (Fedora 27) hosts. My 'scope showed a good solid 12v signal when it was on the RPi. Ran out of time then (other engagements), so will try it on the KRT2 radio tomorrow.
--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

On a sunny day (Sun, 3 Jun 2018 23:13:42 +0000 (UTC)) it happened Martin Gregorie wrote in :

No problem, pins are cheap :-). Sorry for unclear drawing. But for the record:

formatting link
a simple example of interfacing logic level to RS232 level with a MAX232.

Sounds OK. Having a scope is a big plus with all that tronix, still have a 10 MHz analog myself. designed a small digital one too:

formatting link

hey an other MAX232...

:-)

Reply to
Jan Panteltje

Mine's similar: an analog 20MHz Hameg with dual Y channels, bought in the late '80s. "dual scan mode" alternates between the Y channels on successive scans.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

On a sunny day (Mon, 4 Jun 2018 11:23:06 +0000 (UTC)) it happened Martin Gregorie wrote in :

Scope TV:

formatting link

Reply to
Jan Panteltje

A wrap: I now have my Serialport server talking to the KRT2 radio and its client program, which transfers lists of preset frequencies to and from the radio, successfully downloading presets from the radio.

Much of the problem vanished when I replaced the AXE027 cable with my pFranc RS232 USB adapter and added a three-wire cable terminated in a

3.5mm stereo socket to it. This had to be three-wire because the radio, manages to connect power, two mics, two speakers/headphones and either a remote control head or the presets up/down load facility through a single D-15 socket, so no handshake pins are available.

Yesterday, using ptlrc with a carefully crafted script file that drove a partial download, let me verify that the connection was working.

Today I tried making contact over the cable from krt2, my up/download program. This acts as a client to spd, the SerialPort daemon, which drives the USB adapter and runs the link to the radio. It was immediately obvious that krt2 was able to send data to the radio (its display changed state) but that it couldn't receive. I guessed that was probably in the cflag values (set with tcsetattr(), so compared my settings with ptlrc. Where there were differences I swiped the ptlrc settings, mainly that I hadn't set CLOCAL or CREAD, so I set them and also set IGNBRK and IGNPAR in iflag for good measure and because that couldn't do any harm.

Immediate success, so thank you, Jan, for making ptlrc available.

After that all that was needed was to juggle with timings a bit: the KRT2 has a very slow MPU managing it, and needs a 100mS delay between my program requesting the next preset and starting to read it. I'd been warned that the protocol the radio uses to upload and download presets was a bit flaky and poorly documented, so I also had to adjust some assumptions I'd coded into krt2 so they matched the reality shown by my debugging displays.

The result seems to be fairly robust, if not particularly resilient, but its SLOW. Bearing in mind that the link runs at 9600N1, each preset frequency packet contains 11 characters and the request for the next one is a single ACK, the radio takes 13 seconds to assemble and transmit 10 preset packets. Judging by way the Rx and Tx LEDs flash on the USB adapter, 80-90% of that time is taken up by the radio assembling the next

11 character packet.

Anyway, thanks for your help, guys. I learned stuff I didn't know about the varieties of USB adapters available, and somewhat more about serial port setup than I thought I knew.

My next job: add the code to krt2 (the program) to do the reverse transfer, and upload presets to the radio, but that can wait a bit: the glider the KRT2 lives in badly needs some airtime and I need to look at the world from a glider at cloudbase.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.