03. Apparently, in my initial Perl Code, I did not try the 'sleep()' Function.#!/usr/bin/perl #use strict; #use warnings; use Device::SerialPort; use Time::HiRes qw(usleep); sub Handle_FTdx1200{ my $delayValue=100000; my $port = Device::SerialPort->new("/dev/cu.usbserial"); $port->databits(8); $port->baudrate(4800); $port->handshake("rts"); $port->parity("none"); $port->stopbits(1); $port->write_settings || undef $port; $port->write("FA;"); usleep($delayValue); my $VFOA=$port->read(11); $port->write("MD0;"); usleep($delayValue); my $Mode=$port->read(5); $port->write("PC;"); usleep($delayValue); my $Pwr=$port->read(6); $port->close(); $VFOA=substr($VFOA, 2, 8); $Mode=substr($Mode, 3, 1); $Pwr=substr($Pwr, 2, 3); $Pwr=int($Pwr); $Pwr="$Pwr"; return($VFOA, $Mode, $Pwr); } my ($tFreq, $tMode, $tPower)=Handle_FTdx1200(); print($tFreq); print("\n"); print($tMode); print("\n"); print($tPower); print("\n");
In conclusion - again, thank you - to the both of you.set desiredPort to "/dev/cu.usbserial" set tSpeed to "38" try set tPort to serialport open desiredPort bps rate 4800 data bits 8 + parity 0 stop bits 1 handshake 3 delay 0.1 serialport write ("KS;") to tPort delay 0.1 set originalSpeed to serialport read tPort delay 0.1 set originalSpeed to (get (characters 4 through 5 of originalSpeed +) as string) as integer serialport write ("KS0" & tSpeed & ";") to tPort delay 0.1 serialport write ("KS;") to tPort delay 0.1 set currentSpeed to serialport read tPort delay 0.1 set currentSpeed to (get (characters 4 through 5 of currentSpeed) +as string) as integer display dialog "Original Speed: " & originalSpeed & return & "Curr +ent Speed: " & currentSpeed giving up after 5 buttons ("OK") default +button "OK" serialport close tPort on error serialport close tPort end try
In reply to Re: Cannot write to, or read from, the SerialPort
by macdev
in thread Cannot write to, or read from, the SerialPort
by macdev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |