Created
February 23, 2012 01:23
-
-
Save JamesHarrison/1889015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Sets the date and time correctly on the RDS encoder | |
# This is broadcast as RDS metadata (CT) so should be kept accurate | |
# The internal clock of the PC running this script should be synchronized with | |
# a GPS or radio clock or network time server using NTP | |
require 'net/telnet' | |
def run_cmd(cmd,arg) | |
s = "" | |
rds = Net::Telnet::new("Host" => "localhost", "Port" => 2000, "Telnetmode" => false, "Prompt" => /^\+/n) | |
rds.cmd("#{cmd}=#{arg}\n"){|c| s << c.gsub("??", "").gsub("+","")} | |
rds.close | |
return s | |
end | |
t = Time.now | |
puts run_cmd("TIME", t.strftime("%H:%M:%S")) | |
puts run_cmd("DATE", t.strftime("%d.%m.%y")) | |
puts "Set RDS time and date OK to system time" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment