Automatic time update for Scom 7330 Controllers
The Scom 7330 controllers are excellent controllers for Amateur Radio Repeaters.
I’m extremely happy with their performance and would definitely recommend them.
One feature they don’t have is an RTC (Real Time Clock) so over time the internal clocks drifts if it’s not periodically updated.
So to automate the update process I’ve developed a Perl script that can be run by a cron job on an attached Linux computer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#!/usr/bin/perl # #Scom 7330 time update script by Sean Smith VE6SAR # use strict; use POSIX qw(strftime); use Time::HiRes qw(usleep); my $serialPort = "/dev/ttyUSB1"; #Our serial port Windows format is com1 my $PW = "99"; #The master password for the controller my $d = 50000; #Set the character send delay in micro seconds Scom recommends 50ms = 50000us # For Linux use Device::SerialPort; my $port = Device::SerialPort->new($serialPort); # For Windows. You only need one or the other. # Uncomment these for Windows and comment out above #use Win32::SerialPort; #my $port = Win32::SerialPort->new($serialPort); print "Scom 7330 time update script by Sean Smith VE6SAR\n\r"; $port->baudrate(57600); # Configure this to match your device $port->databits(8); $port->parity("none"); $port->stopbits(1); my $ts = strftime("%y %m %d %w %H %M %S", localtime(time)); print "Updating to the current Date and Time\r\n"; my $command = "$PW 25 $ts *\r"; #Send to the controller 1 charactor at a time to keep from overflowing the buffer foreach my $char (split //, $command) { $port->write($char); usleep($d); #sleep to allow the controller time to process each charactor } sleep 2; my $response; #The variable to hold the respose from the controller my ( $blocking_flags, $in_bytes, $out_bytes, $latch_error_flags ) = $port->status() ; $port->lookclear; #clear the buffer sleep (1) ; # Make sure we got a response and display it if( $in_bytes > 0 ) { for( my $i = 0 ; $i < $in_bytes ; $i++ ) { # Get a byte at a time to process. $response .= $port->read( 1 ) ; if( $response =~ /\r/ ) { my $complete = 1 ; } } } print ("Response is:\n $response\n") ; $port->close || die "failed to close"; undef $port; # frees memory back |
Download from GitHub
I made the script executable so it will run automatically.
1 |
chmod +x set_time.pl |
Made sure the user is a member of the dialout group.
1 |
adduser USER dialout |
Now make a cron job to run the script. I’m running mine every Sunday at 5 am, my reasoning is my hourly announcements start at 6 am and when the time switches back and forth for day light savings time it will catch that.
To edit the crontabs type
1 |
crontab -e |
Make the following entry at the end of your crontab file editing it for the location of your Perl script and save it.
1 2 |
# Update the Scom 7330 time and date every Sunday at 05:00 0 5 * * 0 /usr/bin/perl /home/USER/scom/set_time.pl >/dev/null 2>&1 |
All done now my controller time will stay up to date.
The script could be modified to send what ever commands you want to send to the controller. For example run macros to turn on links for a scheduled net etc.
Leave a Reply