01. Thank you for viewing the Code and replying.
02. I will be looking into the 'IO::Termios' Module as suggested by 'haukex'.
03. Viewing various Perl Code Examples ...
$port->write_settings || undef $port;
... was not in some of the Example Code. Thus, I tried my Perl Code with / without 'port->write_settings' used.
I just happened to comment out that Line of Code, on my last Test, before posting my Request.
I will make sure in any new Code, to use: $port->write_settings || undef $port;
04. I beleived I did use 'sleep()' in previous Versions of the Code - before the posted Version - but I will again try using 'sleep()' after each '$port->write("...")'. Thank you for the Suggestion.
05. "I am curious as to your actual application and whether or not you have to co-exist with some other application?"
With repect to Python - No. I have wriiten well over 100 '.py' Script Files for the many Amateur Radio Contests which happen over the Year. My Scripts may call some personally written Modules for commonly used Routines - such as the Sample Python below; but the Scripts are not reliant on any external Application(s).
Please see '06.' about 'co-exist with some other application(s)'.
06. "My friend has two apps which want to talk to the same radio serial port ..." - correct, with respect to possible Conflicts.
My Python Code closes the Serial Port once an Action is performed. However, once I had 'FLDIGI' running, using 'FLRIG' as its Frequency Controller. I then executed an AppleScript Applet to change the Power Output of my Transceiver - and it complained. Once I quitted 'FLDIGI' and 'FLRIG', the AppleScript worked just find. Either one or both - 'FLDIGI' and / or 'FLRIG' keep sampling the Serial Port; thus, it was never closed.
The same would happen if I tried to run a Python Script, requiring access to the Serial Port - if 'FLDIGI' and "FLRIG' were running.
07. I do thank you for the Suggestions.
Below is only one (1) of many Python Functions / Methods / Procedures I use for accessing Yaesu Transceivers - this may assist you in your Perl Version for your Friend.
------------------------------------------------------------
Python Function / Method / Procedure for obtaining the VFO-A Frequency, in Hz; the Mode - 'LSB', 'USB', 'CW', 'FM', 'AM', 'RTTY-LSB', 'CW-R', 'DATA-LSB', 'RTTY-USB', '----', 'FM-N', or 'DATA-USB'; and Output Power, in Watts, of the Transceiver
----
def Handle_FTdx1200():
lSer=serial.Serial('/dev/cu.usbserial', 4800)
# Open a Serial Port, and configure its Baud Rate.
lSer.write('FA;'.encode())
# Tell FTdx-1200 to obtain 'FA' VFO-A Frequency.
lFreq=lSer.read(11)
# Retrieve the 'FA' Data
lSer.flush()
# Purge the Input Buffer of any Characters.
lSer.write('MD0;'.encode())
# Tell FTdx-1200 to obtain 'MD' Module.
lMode=lSer.read(5)
# Retrieve the 'MD' Data
lSer.flush()
# Purge the Input Buffer of any Characters.
lSer.write('PC;'.encode())
# Tell FTdx-1200 to obtain 'PC' lPower Output Value.
lPower=lSer.read(6)
# Retrieve the 'PC' Data
lSer.close()
# Close the Connection of the USB Serial Adapter.
lFreq=lFreq[2:10]
# Remove 'FA' and ending ';'
lFreq=lFreq.decode("utf-8")
# Without '.decode("utf-8")' 'lFreq' would be printed,
#in the print Line below
# "b'XXX', where XXX is the Value of lFreq.
lPower=lPower[2:5]
# Remove 'PC' and ending ';'
#lPower=str(int(lPower))
# If 'lPower' is less than 100 a preceding '0' will appear.
#This Code removes the preceding '0'.
lPower=lPower.decode("utf-8")
lMode=lMode[3:4]
lMode=lMode.decode("utf-8")
# Without '.decode("utf-8")' 'lMode' would be printed,
#in the print Line below as "b'XXX', where XXX is the Value of lMode.
if((lMode=='3') or (lMode=='7')):
lMode='CW'
elif((lMode=='1') or (lMode=='2')):
lMode='PH'
elif(lMode=='5'):
lMode='AM'
elif((lMode=='4') or (lMode=='B')):
lMode='FM'
elif((lMode=='8') or (lMode=='C')):
lMode='DG'
elif((lMode=='6') or (lMode=='9')):
lMode='RY'
else:
lMode='---'
return(lFreq, lMode, lPower)
----
The above Code works flawlessly at the FTdx-1200 default Baud Rate of 4800; as well at - 9600, 19200, and 38400 bps.
------------------------------------------------------------
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.