summaryrefslogtreecommitdiff
path: root/src/pira32ctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/pira32ctl')
-rw-r--r--src/pira32ctl/command.go167
1 files changed, 147 insertions, 20 deletions
diff --git a/src/pira32ctl/command.go b/src/pira32ctl/command.go
index ad399c8..9291ef9 100644
--- a/src/pira32ctl/command.go
+++ b/src/pira32ctl/command.go
@@ -32,11 +32,49 @@ const (
RESP_UNKNOWN_CMD = '!'
RESP_INVALID_ARG = '-'
RESP_PARTIAL = '/'
+
+ storeExecutionTime = 10 * time.Millisecond
)
-type command struct {
+type Command interface {
+ AllowedMethods() (get, assign, store, assignstore bool)
+}
+
+type BasicCommand struct {
+ code string
+ description string
+ exec_time time.Duration
+ get bool
+ assign bool
+ store bool
+ assignStore bool
+}
+
+func (c BasicCommand) AllowedMethods() (bool, bool, bool, bool) {
+ return c.get, c.assign, c.store, c.assignStore
+}
+
+type ParamCommand struct {
+ code string
+ description string
+ rangeMin uint
+ rangeMax uint
+ exec_time time.Duration
+ get bool
+ assign bool
+ store bool
+ assignStore bool
+}
+
+func (c ParamCommand) AllowedMethods() (bool, bool, bool, bool) {
+ return c.get, c.assign, c.store, c.assignStore
+}
+
+type Param2Command struct {
code string
description string
+ rangeMin uint
+ rangeMax uint
exec_time time.Duration
get bool
assign bool
@@ -44,24 +82,113 @@ type command struct {
assignStore bool
}
+func (c Param2Command) AllowedMethods() (bool, bool, bool, bool) {
+ return c.get, c.assign, c.store, c.assignStore
+}
+
var (
- CMD_AF = command{"AF", "Alternative Frequencies", 0, true, true, true, true}
- CMD_AFCH = command{"AFCH", "Alternative Frequencies Channels", 0, true, true, true, false}
- CMD_DI = command{"DI", "Decoder Identification", 0, true, true, true, false}
- CMD_DPS1 = command{"DPS1", "Dynamic PS1", 400 * time.Millisecond, true, true, true, false}
- CMD_DPS1ENQ = command{"DPS1ENQ", "Dynamic PS1 Enqueue", 400 * time.Millisecond, false, true, false, false}
- CMD_DPS2 = command{"DPS2", "Dynamic PS2", 400 * time.Millisecond, true, true, true, false}
- CMD_DPS1MOD = command{"DPS1MOD", "Dynamic PS1 Mode", 400 * time.Millisecond, true, true, true, false}
- CMD_DPS2MOD = command{"DPS2MOD", "Dynamic PS2 Mode", 400 * time.Millisecond, true, true, true, false}
- CMD_DPS1REP = command{"DPS1REP", "Dynamic PS2 Number of Repeating", 400 * time.Millisecond, true, true, true, false}
- CMD_DPS2REP = command{"DPS2REP", "Dynamic PS2 Number of Repeating", 400 * time.Millisecond, true, true, true, false}
- CMD_DTTMOUT = command{"DTTMOUT", "Default Text Timeout", 0, true, true, true, false}
- CMD_EQTEXT1 = command{"EQTEXT1", "Equal Text 1", 0, true, true, true, false}
- CMD_LABPER = command{"LABPER", "Label Period", 0, true, true, true, false}
- CMD_MS = command{"MS", "Music/Speech", 0, true, true, true, false}
- CMD_PI = command{"PI", "Program Identifaction", 0, true, true, true, false}
- CMD_PS = command{"PS", "Program Service name", 0, true, true, true, false}
- CMD_PTY = command{"PTY", "Program Type number", 0, true, true, true, false}
- CMD_PTYN = command{"PTYN", "Program Type Name", 0, true, true, true, false}
- CMD_PTYNEN = command{"PTYNEN", "PTYN Enable", 0, true, true, true, false}
+ // Basic:
+ CMD_AF = BasicCommand{"AF", "Alternative Frequencies", 0, true, true, true, true}
+ CMD_AFCH = BasicCommand{"AFCH", "Alternative Frequencies Channels", 0, true, true, true, false}
+ CMD_DI = BasicCommand{"DI", "Decoder Identification", 0, true, true, true, false}
+ CMD_DPS1 = BasicCommand{"DPS1", "Dynamic PS1", 400 * time.Millisecond, true, true, true, false}
+ CMD_DPS1ENQ = BasicCommand{"DPS1ENQ", "Dynamic PS1 Enqueue", 400 * time.Millisecond, false, true, false, false}
+ CMD_DPS2 = BasicCommand{"DPS2", "Dynamic PS2", 400 * time.Millisecond, true, true, true, false}
+ CMD_DPS1MOD = BasicCommand{"DPS1MOD", "Dynamic PS1 Mode", 400 * time.Millisecond, true, true, true, false}
+ CMD_DPS2MOD = BasicCommand{"DPS2MOD", "Dynamic PS2 Mode", 400 * time.Millisecond, true, true, true, false}
+ CMD_DPS1REP = BasicCommand{"DPS1REP", "Dynamic PS2 Number of Repeating", 400 * time.Millisecond, true, true, true, false}
+ CMD_DPS2REP = BasicCommand{"DPS2REP", "Dynamic PS2 Number of Repeating", 400 * time.Millisecond, true, true, true, false}
+ CMD_DTTMOUT = BasicCommand{"DTTMOUT", "Default Text Timeout", 0, true, true, true, false}
+ CMD_EQTEXT1 = BasicCommand{"EQTEXT1", "Equal Text 1", 0, true, true, true, false}
+ CMD_LABPER = BasicCommand{"LABPER", "Label Period", 0, true, true, true, false}
+ CMD_MS = BasicCommand{"MS", "Music/Speech", 0, true, true, true, false}
+ CMD_PI = BasicCommand{"PI", "Program Identifaction", 0, true, true, true, false}
+ CMD_PS = BasicCommand{"PS", "Program Service name", 400 * time.Millisecond, true, true, true, false}
+ CMD_PTY = BasicCommand{"PTY", "Program Type number", 0, true, true, true, false}
+ CMD_PTYN = BasicCommand{"PTYN", "Program Type Name", 0, true, true, true, false}
+ CMD_PTYNEN = BasicCommand{"PTYNEN", "PTYN Enable", 0, true, true, true, false}
+ CMD_RT1 = BasicCommand{"RT1", "Radiotext 1", 0, true, true, true, false}
+ CMD_RT1EN = BasicCommand{"RT1EN", "RT1 Enable", 0, true, true, true, false}
+ CMD_RT2 = BasicCommand{"RT2", "Radiotext 2", 0, true, true, true, false}
+ CMD_RT2EN = BasicCommand{"RT2EN", "RT2 Enable", 0, true, true, true, false}
+ CMD_RTPER = BasicCommand{"RTPER", "Radiotext Switching Period", 0, true, true, true, false}
+ CMD_RSTDPS = BasicCommand{"RSTDPS", "Rerstart Dynamic PS", 0, true, true, true, false}
+ CMD_SCRLSPD = BasicCommand{"SCRLSPD", "Scrolling PS Speed", 0, true, true, true, false}
+ CMD_SPSPER = BasicCommand{"SPSPER", "Static PS Period", 0, true, true, true, false}
+ CMD_TA = BasicCommand{"TA", "Traffic Announcement", 0, true, true, true, false}
+ CMD_TATMOUT = BasicCommand{"TATMOUT", "TA TImeout", 0, true, true, true, false}
+ CMD_TP = BasicCommand{"TP", "Traffic Program", 0, true, true, true, false}
+ CMD_TPS = BasicCommand{"TPS", "Traffic PS", 400 * time.Millisecond, true, true, true, false}
+ CMD_INIT = BasicCommand{"INIT", "Initialization", 0, true, false, false, false}
+ CMD_STOREALL = BasicCommand{"ALL", "Store All", 0, false, false, true, false}
+ CMD_HELP = BasicCommand{"HELP", "Help", 0, true, false, false, false}
+
+ // EON:
+ CMD_EON_AF = ParamCommand{"EONxAF", "EON x Frequencies", 1, 4, 0, true, true, false, false}
+ CMD_EON_AFCH = ParamCommand{"EONxAFCH", "EON x Frequency channels", 1, 4, 0, true, true, false, false}
+ CMD_EON_EN = ParamCommand{"EONxEN", "EON x Enable", 1, 4, 0, true, true, false, false}
+ CMD_EON_PI = ParamCommand{"EONxPI", "EON x Program Identification", 1, 4, 0, true, true, false, false}
+ CMD_EON_PIN = ParamCommand{"EONxPIN", "EON x Program Item Number", 1, 4, 0, true, true, false, false}
+ CMD_EON_PS = ParamCommand{"EONxPS", "EON x Program Service name", 1, 4, 0, true, true, false, false}
+ CMD_EON_PTY = ParamCommand{"EONxPTY", "EON x Program Type number", 1, 4, 0, true, true, false, false}
+ CMD_EON_TA = ParamCommand{"EONxTA", "EON x Traffic Announcement", 1, 4, 0, true, true, false, false}
+ CMD_EON_TP = ParamCommand{"EONxTA", "EON x Traffic Program", 1, 4, 0, true, true, false, false}
+ CMD_EON = ParamCommand{"EON", "Store all EON data into EEPROM", 1, 4, 50 * time.Millisecond, false, false, true, false}
+
+ //Messages:
+ CMD_MSG = Param2Command{"MSGxx", "Text message", 1, 99, 0, true, false, false, true}
+ CMD_MSG_D = Param2Command{"MSGxxD", "Message Destination", 1, 99, 0, true, false, false, true}
+ CMD_MSGLIST = BasicCommand{"MSGLIST", "List of Messages", 0, true, false, false, false}
+ CMD_DPS2MSG = BasicCommand{"DPS2MSG", "Dynamic PS 2 Message Number", 0, true, true, true, false}
+ CMD_RT2MSG = BasicCommand{"RT2MSG", "Radiotext 2 Message NUmber", 0, true, true, true, false}
+
+ //Scheduling:
+ CMD_SLIST = BasicCommand{"SLIST", "List of Scheduling Items", 0, true, false, false, false}
+ CMD_S_C = Param2Command{"SxxC", "Scheduling Item Command", 1, 48, 0, true, false, false, true}
+ CMD_S_D = Param2Command{"SxxD", "Scheduling Item Days", 1, 48, 0, true, false, false, true}
+ CMD_S_P = Param2Command{"SxxP", "Scheduling Item PTY", 1, 48, 0, true, false, false, true}
+ CMD_S_T = Param2Command{"SxxT", "Scheduling Item Times", 1, 48, 0, true, false, false, true}
+ CMD_SEN = BasicCommand{"SEN", "Scheduling Enable", 0, true, true, true, false}
+
+ // System:
+ CMD_COMSPD = BasicCommand{"COMSPD", "Com Port Speed", 0, true, true, true, false}
+ CMD_CT = BasicCommand{"CT", "CLock Time and Date", 0, true, true, true, false}
+ CMD_DATE = BasicCommand{"Date", "Date", 0, true, true, true, false}
+ CMD_ECHO = BasicCommand{"ECHO", "Terminal Echo", 0, true, true, true, false}
+ CMD_EXTSYNC = BasicCommand{"EXTSYNC", "External Pilot Synchronisation", 0, true, true, true, false}
+ CMD_LEVEL = BasicCommand{"LEVEL", "RDS Signal Level", 0, true, true, true, false}
+ CMD_LTO = BasicCommand{"LTO", "Local Time Offset", 0, true, true, true, false}
+ CMD_MJD = BasicCommand{"MJD", "Modified Julian Day", 0, true, true, true, false}
+ CMD_PHASE = BasicCommand{"PHASE", "RDS Signal Phase", 0, true, true, true, false}
+ CMD_PILOT = BasicCommand{"PILOT", "Pilot Tone Present", 0, true, false, false, false}
+ CMD_RDSGEN = BasicCommand{"RDSGEN", "RDS Generator", 0, true, true, true, false}
+ CMD_RESET = BasicCommand{"RESET", "Reset", 0, true, false, false, false}
+ CMD_SPEED = BasicCommand{"SPEED", "Com Port Speed", 0, true, true, true, false}
+ CMD_STATUS = BasicCommand{"STATUS", "RDS Encoder Status", 0, true, false, false, false}
+ CMD_TIME = BasicCommand{"TIME", "Time", 0, true, true, true, false}
+ CMD_VER = BasicCommand{"VER", "Firmware Version", 0, true, false, false, false}
+
+ // Advanved:
+ CMD_ADR = BasicCommand{"ADR", "Encoder Address List", 0, true, false, false, true}
+ CMD_CC = BasicCommand{"CC", "Conditional Command", 0, true, false, false, true}
+ CMD_DSN = ParamCommand{"DSNx", "Program x Data Set Number", 1, 2, 0, true, false, false, true}
+ CMD_ECC = BasicCommand{"ECC", "Extended Country Code", 0, true, true, true, false}
+ CMD_ECCEN = BasicCommand{"ECCEN", "ECC and LIC Enable", 0, true, true, true, false}
+ CMD_G = BasicCommand{"G", "Group", 200 * time.Millisecond, false, true, false, false}
+ CMD_GRPSEQ = BasicCommand{"GRPSEQ", "Group Sequeunce", 0, true, true, true, false}
+ CMD_LIC = BasicCommand{"LIC", "Language Identification Code", 0, true, true, true, false}
+ CMD_NOHDR = BasicCommand{"NOHDR", "No Header Communication", 0, true, false, false, true}
+ CMD_PIN = BasicCommand{"PIN", "Program Item Number", 0, true, true, true, false}
+ CMD_PINEN = BasicCommand{"PINEN", "PIN Enable", 0, true, true, true, false}
+ CMD_PROGRAM = BasicCommand{"PROGRAM", "Program Set Selection", 0, true, true, true, false}
+ CMD_PSN = ParamCommand{"PSNx", "Program x Service Number", 1, 2, 0, true, false, false, true}
+ CMD_PSW = BasicCommand{"PSW", "PS Window", 0, true, false, false, false}
+ CMD_RTP = BasicCommand{"RTP", "Radiotext Plus Tagging Data", 0, true, true, false, false}
+ CMD_RTPRUN = BasicCommand{"RTPRUN", "Radiotext Plus Running Bit", 0, true, true, false, false}
+ CMD_SEL = BasicCommand{"SEL", "Select Encoder", 0, false, true, false, false}
+ CMD_SHORTRT = BasicCommand{"SEL", "Short Radiotext", 0, true, true, true, false}
+ CMD_SITE = BasicCommand{"SITE", "Site Address List", 0, true, false, false, true}
+ CMD_UDG1 = BasicCommand{"UDG1", "User Defined Groups 1", 0, true, true, true, false}
+ CMD_UDG2 = BasicCommand{"UDG2", "User Defined Groups 2", 0, true, true, true, false}
+ CMD_UECP = BasicCommand{"UECP", "UECP Enable", 0, true, true, true, false}
)