-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprais.h
164 lines (140 loc) · 5.5 KB
/
prais.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright (C) 2013 Nick Kossifidis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* prais.h - Support for Prais Coder mod. 735
* (and possibly 732 but haven't tested it)
*/
/******************************\
* DATA LINK CONTROL CHARACTERS *
\******************************/
/* These are common ASCII control characters
* used for signaling on the serial port */
#define PRAIS_DL_SYN 0x16 /* SYNchronize */
#define PRAIS_DL_SOH 0x01 /* Start Of Header */
#define PRAIS_DL_ACK 0x06 /* ACK */
#define PRAIS_DL_DLE 0x10 /* Data Link Escape */
#define PRAIS_DL_STX 0x02 /* Start of TeXt */
#define PRAIS_DL_ETX 0x03 /* End of TeXt */
/*****************\
* MESSAGE FORMATS *
\*****************/
/* A Message for Prais Coder mod. 735 */
struct prais_message {
uint8_t type; /* Message type code */
uint8_t len; /* Message len */
uint8_t data[40]; /* Message */
uint16_t checksum; /* The sum of type and data fields
* cut to one byte (ANDed with 0xFF)
* and transmitted as two ascii chars */
};
/* Message types */
#define PRAIS_MT_RESET 0x00 /* Unit reset */
#define PRAIS_MT_RDSON 0x01 /* RDS Enable */
#define PRAIS_MT_LOCK_STATUS 0x02 /* RDS Lock status request */
#define PRAIS_MT_TAMSDI 0x03 /* Traffic Anouncement, M/S switch and Decoder Info */
#define PRAIS_MT_UNITMSG 0x04 /* Unit Message (?) */
#define PRAIS_MT_AF 0x05 /* Alternative Frequencies */
#define PRAIS_MT_STORE 0x06 /* Store data on device */
#define PRAIS_MT_SERIAL_NUM 0x08 /* Unit serial number request / set unit address */
#define PRAIS_MT_PI 0x09 /* Programme Identifier */
#define PRAIS_MT_PS 0x0A /* Programme Service Name */
#define PRAIS_MT_RTC 0x0B /* Real Time Clock */
#define PRAIS_MT_PTY 0x0C /* Programme Type */
#define PRAIS_MT_TDC 0x0D /* Traffic Data Channel data -unsupported- */
#define PRAIS_MT_IH 0x0E /* In House data -unsupported- */
#define PRAIS_MT_RT 0x0F /* RadioText */
#define PRAIS_MT_MIN_VAL PRAIS_MT_RESET
#define PRAIS_MT_MAX_VAL PRAIS_MT_RT
#define PRAIS_MT_MAX_LEN 40
/* Prais RT related */
#define PRAIS_RT_SPACE_LENGTH 8
/* A data frame for Prais Coder mod. 735 */
struct prais_data_frame {
uint8_t no_reply; /* Set the no reply flag */
struct prais_message msg;
};
/* The no reply flag is set on the high byte
* of the address field */
#define PRAIS_DF_NO_REPLY 0x8000
/* Broadcast address */
#define PRAIS_DF_ADDR_BCAST 0xFFFF
/* Sequence number is 0 - 9 ASCII */
#define PRAIS_DF_SEQ_MIN 0x30
#define PRAIS_DF_SEQ_MAX 0x39
#define PRAIS_DF_MAX_LEN 48
/**********\
* COMMANDS *
\**********/
/**
* DOC: Hardware capabilities (Prais Coder mod. 735)
*
* NOTE: Only one programme is supported by the hw.
*
* In all commands that accept DSN and PSN, except the PS command,
* any non-zero value for DSN and PSN will result an error.
*
* NOTE: Unit has the ability to handle dynamic PS on hw.
*
* Only one programme is supported by the device
* but 2 message groups are provided, each one for
* handling dynamic PS (for this single programme)
* on hw. Each message group contains 15 messages and
* a number of retransmissions for each message (up to 100),
* forming a message queue to be transmitted. User can
* change the active message group by using a physical switch
* on the unit's front panel.
*
* In general we don't support dynamic PS on hw because it's
* not flexible and it breaks abstraction with other devices
* (e.g. we need an extra input for number of retransmissions),
* so we always set a single message per message group. To enable
* dynamic PS hw support, set the RDS_ENCODER_FLAGS_PRAIS_HW_DYNPS
* and use dsn as the message group and psn as the message index on
* that message group. Since there is no way to provide number of
* retransmissions, we set the number of retransmissions to 10 for
* the first group entry (e.g. the station's name) and 4 for all the
* rest.
*
* Even when not using this feature, dsn can still be used to set an
* alternative PS on group 2 so that the user can still use the physical
* switch, e.g. to switch to a backup PS. PSN however still needs to be 0.
*/
/* Flags for the T.A., M/S, DI field */
#define PRAIS_TAMSDI_TA_ON 0x02
#define PRAIS_TAMSDI_TP_ON 0x04
#define PRAIS_TAMSDI_MS_MUSIC 0x40
#define PRAIS_TAMSDI_DI_STEREO 0x01
#define PRAIS_TAMSDI_DI_ART_HEAD 0x08
#define PRAIS_TAMSDI_DI_COMPRESSED 0x10
#define PRAIS_TAMSDI_DYNPTY 0x20
#define PRAIS_TAMSDI_TATP_ON 0x80 /* Got this on reply after
* requesting TAMSDI with
* both TA/TP flags on.
*/
#define PRAIS_TAMSDI_TATP_MASK (PRAIS_TAMSDI_TA_ON |\
PRAIS_TAMSDI_TP_ON)
#define PRAIS_TAMSDI_DI_MASK (PRAIS_TAMSDI_DI_STEREO |\
PRAIS_TAMSDI_DI_ART_HEAD |\
PRAIS_TAMSDI_DI_COMPRESSED)
/* Programme Service */
/* Flag to add to the index field to indicate message group 2 */
#define PRAIS_PSN_INDEX_GROUP2 0x80
/************\
* PROTOTYPES *
\************/
int prais_init(struct rds_encoder *enc);