Skip to content

Instantly share code, notes, and snippets.

@JamesHarrison
Created February 23, 2012 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesHarrison/1889015 to your computer and use it in GitHub Desktop.
Save JamesHarrison/1889015 to your computer and use it in GitHub Desktop.
#!/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