Set 7300 Clock

Set 7300 clock is a utility application to set the internal clock in your ICOM 7300 transceiver using the time from your PC.

There are two versions of this application, a C# command line program and a PowerShell script.

Example source code is provided in both PowerShell and C#

Command Line Program

Set 7300 Clock image

There are several ham radio applications that, when they startup, have the ability to start other programs as well. Some examples are fldigi and wsjt-x. Several people have found this to be a convenient way to keep their radio's clock synchronized by running set-7300clock as an autostart application. Both the PowerShell and C# versions of set-7300clock were originally intended to be used stand alone or to serve as examples, so neither of them include very robust error checking, collision detection, or retry attempts. Thses features become very important when multiple applications are communicating with the radio over the CI-V bus at the same time or with shared serial ports. So that people can use set-7300clock in conjunction with other CI-V programs, I have modified the command line program to share the same CI-V communication code used by ICOM 7300 Memory Manager, which does include all of the features mentioned above.

This updated version of set-7300clock can be used as an autostart program with other application such as fldigi or wsjt-x. The program works in the same way as the prior version, but the command line options have changed slightly. I have switched to using the Microsoft System.Commandline library for parsing the command line which makes that job much easier. However, it also required me to change how some of the options are specified on the command line.

Here are the command line options for set-7300clock

Description:
  Set the internal clock on selected ICOM radios. The source for the time can be the computer's clock or an NTP server. There are options
  to use UTC vs. local time, set the clock immediately without waiting for the seconds to roll over to the next minute, suppress console
  output, and to set communication parameters.

Usage:
  Set-7300Clock [options]

Options:
  -p, --port <COM10|COM5|COM7|COM8|COM9> (REQUIRED)     The COM port connected to the radio.
  -b, --baud <115200|19200|38400|4800|57600|9600>       The baud rate to use to communicate with the radio [default: 115200]
  -t, --timeout <timeout>                               Timeout for reads im milliseconds [default: 1000]
  -q, --quiet                                           Don't display prompts to the console [default: False]
  -i, --immediate                                       Set clock immediately without waiting for the seconds to become zero [default:
                                                        False]
  -u, --utc                                             Use UTC time rather than local time [default: False]
  -m, --model <ICOM705|ICOM7300|ICOM7610|ICOM9700>      The model of ICOM radio [default: ICOM7300]
  -a, --address <address>                               The CI-V address of the ICOM radio. Default is based on radio model (IC7300
                                                        shown). Use this if you have changed the CI-V address in the radio from the
                                                        default [default: 148]
  -s, --server <server>                                 An optional NTP server to use as the source for the current time. If contacting
                                                        the server fails the program will not set the clock unless the --fallback option
                                                        is set to true. [default: None]
  -f, --fallback                                        When contacting the NTP server fails, fallback to using the system clock. Used in
                                                        conjunction with the --server option [default: False]
  -d, --debug <Debug|Information|None|Verbose|Warning>  Turn on debug logging. Order of severity is None, Warning, Information, Debug,
                                                        Verbose. [default: None]
  --version                                             Show version information
  -?, -h, --help                                        Show help and usage information

                        
An example command is:

set-7300clock --port comport --baud baudrate

or alternatively you can use

set-7300clock -p comport -b baudrate

There are some changes in options and option handling that I need to discuss here.

  • The System.Commandline library uses "--" rather than "-" to specify command line options. Since the library enforces that convention by default I have followed it. However I have defined an alias for most of the commands that uses "-" in addition to "--". So you should be able to use either way to specify command line options.
  • In previous versions of set-7300clock, you could specify the COM port and baud rate by position in the command line. This new version requires that you use -p or --port to specify the port and -b or --baud to optionally specify the baud rate. The only required option is the COM port, which must be specified in all upper case.

    Previously you could use:

    set-7300clock COM1 115200

    Now you have to specify them as follows:

    set-7300clock -p COM1 -b 115200

  • There are several new options:
    • The timeout option permits you to specify the number of milliseconds before a timeout occurs when waiting for a response from the radio. The prior default was 500 milliseconds, but it proved to be advantageous to permit adjusting this on some slower systems or those using virtual COM ports. I also changed the default to 1000 milliseconds.
    • The quiet option causes all routine prompts and messages coming from the program to be suppressed. Error messages will still be displayed. If you specify the --quiet option without the --immediate option the program will still wait for the clock to roll over to the next minute. However you will not receive any feedback regarding how long the program needs to wait for that roll over to occur. When this happens it might appear that the program is hung or stuck, but it is just waiting for the seconds to roll over to the next minute.
    • The immediate option was suggested to me by SA7CND Poul. If this option is specified the program will not wait for the time to roll over to the next minute. Instead, the program will immediately set the clock to the current minute if seconds are less than 30, or the current minute + 1 if seconds are greater than or equal to 30. The clock will still be within 30 seconds of the current time and there will be no delay while the program waits for the time to roll over to the next minute

      For example, if the current time is 08:34:15 and the immediate options is specified, the clock will be set to 08:34. However, if the current time is 08:34:42 and the immediate option is specified, the clock will be set to 08:35.

      Note: This option does take into account the possibility that adding one minute to the current time will potentially change the hour, day, month, or year when setting the clock.
    • The server option lets you specify an NTP server to use as the source for the current time. If the program is unable to contact the server the clock is not set unless you specify the fallback option. In that case the program will use the computer's clock.
    • The fallback option is used in conjunction with the server option. When the program is unable to contact the specified NTP server, the fallback option will have the program set the time to the computer's clock.
    • The help option displays the description, usage, and options information shown above.
    • The version option displays the version number of this program.
    • The address option is useful when you have changed the CI-V address in the radio from the default. You can specify the address in decimal or hexadecimal.
    • The model option lets you select the model of ICOM radio. Currently the 7300, 7610, 705 and 9700 are supported.
    • The debug option is for use in debugging the program if things go wrong. Hopefully it won't be needed very often.

I will continue to provide the example C# source code I had posted previously although it no longer matches the actual set-7300clock program.

PowerShell Script

Set 7300 Clock image

The PowerShell script is simple to use, and being a script the source is there for modification, to serve as an example, or as the basis for further development. This script is for people who either have already enabled PowerShell or don't mind enabling it to be able to run this script. PowerShell is a very powerful tool, but there are security implications to enabling PowerShell script execution, so do your homework before you enable PowerShell script execution. There are lots of references on the Web regarding how to enable script execution and the potential security risks.

Using the script in its' most basic form is simple:

Set-7300Clock comport baudrate

This will set the clock of an Icom 7300 connected to the computer on the specified comport communicating at the specified baud rate.

There is help and some minimal documentation built into the script. I may add more detailed documentation as time permits.

Release History

  • 21-Nov-2023 - Added options for using an NTP server as the time source
  • 07-Nov-2023 - Added command line parsing, error checking, collision detection, and retries. Set UTC offset in the radio.
  • 05-May-2020 - Added command line switch to set the radio to UTC rather than local time
  • 23-Apr-2020 - I just discovered a fairly serious bug in my error checking code.  Please make sure you are using a version of the program created on or after 4/23/2020.  I also plan to add a version number to help track which version of the application is being used.
  • 18-Apr-2020 - Updated both versions of the application to include error checking after setting the date and time.  This should handle COM port errors a bit better and also confirm that the date and time were actually set.
  • 14-Jul-2019 - Initial release

If you want to encourage me to continue developing software you can