if482.cpp + gpsread.cpp sanitized

This commit is contained in:
Klaus K Wilting 2019-01-26 12:32:58 +01:00
parent 79a963b34f
commit f87a0abff7
2 changed files with 61 additions and 44 deletions

View File

@ -10,7 +10,7 @@ gpsStatus_t gps_status;
TaskHandle_t GpsTask;
#ifdef GPS_SERIAL
HardwareSerial GPS_Serial(1);
HardwareSerial GPS_Serial(1); // use UART #1
#endif
// initialize and configure GPS

View File

@ -2,48 +2,65 @@
/*
IF482 Generator to control clocks with IF482 timeframe input (e.g. BÜRK BU190)
IF482 Generator to control clocks with IF482 telegram input (e.g. BÜRK BU190)
Example IF482 timeframe: "OAL160806F170400"
Example IF482 telegram: "OAL160806F170400"
IF482 Specification:
https://www.buerk-mobatime.de/cfc/shop.cfc?method=deliverShopDoc&id=509
http://www.mobatime.com/fileadmin/user_upload/downloads/TE-112023.pdf
Standard Zeittelegramm (IF 482) mit lokaler Zeit
The IF 482 telegram is a time telegram, which sends the time and date
information as ASCII characters through the serial interface RS 232 or RS 422.
Definition: Zeittelegramm (ASCII), endend auf die im Telegramm bezeichnete
Sekunde: 9600 Bit/s, 7 Datenbits, gerade Parität, 1 Stoppbit. Jitter < 50ms.
Communication parameters:
Format:
Byte Bedeutung Zeichen HEX Code
1 Startzeichen O 4F
2 Überwachung* A 41
3 Lokale Zeit** (durch die Uhr angezeigt) L 4C
4 Jahr Zehner 0 .. 9 30 .. 39
5 Jahr Einer 0 .. 9 30 .. 39
6 Monat Zehner 0 oder 1 30 oder 31
7 Monat Einer 0 .. 9 30 .. 39
8 Tag Zehner 0 .. 3 30 .. 33
9 Tag Einer 0 .. 9 30 .. 39
10 nicht verwendet F 46
11 Stunden Zehner 0 .. 2 30 .. 32
12 Stunden Einer 0 .. 9 30 .. 39
13 Minuten Zehner 0 .. 5 30 .. 35
14 Minuten Einer 0 .. 9 30 .. 39
15 Sekunden Zehner 0 .. 5 30 .. 35
16 Sekunden Einer 0 .. 9 30 .. 39
17 Ende des Telegramms CR 0D
Baud rate: 9600 Bit/s
Data bits 7
Parity: even
Stop bit: 1
Jitter: < 50ms
*) Überwachung:
'A': Korrekter Zeitempfang des Sendegerätes
'M': Sendegerät hat mehr als 12 Stunden kein Zeitsignal empfangen
Zeit wird bei 'A' und 'M' vom Uhrwerk übernommen.
Interface : RS232 or RS422
**) Lokale Zeit:
'W': Winterzeit
'S': Sommerzeit
'L': Lokalzeit
Wird überprüft, jedoch nicht vom Uhrwerk ausgewertet.
Synchronization: Telegram ends at the beginning of the second
specified in the telegram
Cycle: 1 second
Format of ASCII telegram string:
Byte Meaning ASCII Hex
1 Start of telegram O 4F
2 Monitoring* A 41
3 Time-Season** W/S/U/L 57 or 53
4 Year tens 0 .. 9 30 .. 39
5 Year unit 0 .. 9 30 .. 39
6 Month tens 0 or 1 30 or 31
7 Month unit 0 .. 9 30 .. 39
8 Day tens 0 .. 3 30 .. 33
9 Day unit 0 .. 9 30 .. 39
10 Day of week*** 1 .. 7 31 .. 37
11 Hours tens 0 .. 2 30 .. 32
12 Hours unit 0 .. 9 30 .. 39
13 Minutes tens 0 .. 5 30 .. 35
14 Minutes unit 0 .. 9 30 .. 39
15 Seconds tens 0 .. 5 30 .. 35
16 Seconds unit 0 .. 9 30 .. 39
17 End of telegram CR 0D
*) Monitoring:
With a correctly received time in the sender unit, the ASCII character 'A' is
issued. If 'M' is issued, this indicates that the sender was unable to receive
any time signal for over 12 hours (time is accepted with A and M).
**) Season:
W: Standard time,
S: Season time,
U: UTC time (not supported by all systems),
L: Local Time
***) Day of week:
not evaluated by model BU-190
*/
@ -52,13 +69,13 @@ Wird überprüft, jedoch nicht vom Uhrwerk ausgewertet.
// Local logging tag
static const char TAG[] = "main";
HardwareSerial IF482(IF482_PORT); // serial port 1
HardwareSerial IF482(1); // use UART #1
// initialize and configure GPS
void if482_init(void) {
// open serial interface
IF482.begin(HAS_IF482);
ESP_LOGI(TAG, "IF482 serial port opened");
// use rtc 1Hz clock for triggering IF482 telegram send
Rtc.SetSquareWavePinClockFrequency(DS3231SquareWaveClock_1Hz);
@ -67,11 +84,13 @@ void if482_init(void) {
// setup external interupt for active low RTC INT pin
attachInterrupt(RTC_INT, IF482IRQ, FALLING);
ESP_LOGI(TAG, "IF482 generator initialized");
} // if482_init
char *if482Telegram(time_t t) {
static char out[17] = {0}; // 16 bytes IF482 telegram plus null termination char
static char out[17] = {0}; // 16 bytes IF482 telegram + null termination char
char buf[14] = {0};
strcat_P(out, "O"); // <STX>
@ -95,8 +114,8 @@ char * if482Telegram(time_t t) {
strcat_P(out, "L"); // local time
if (!timeNotSet) { // do we have valid time?
sprintf(buf, "%02u%02u%02uF%02u%02u%02u", year(t), month(t), day(t), hour(t),
minute(t), second(t));
sprintf(buf, "%02u%02u%02u%1u%02u%02u%02u", year(t), month(t), day(t),
weekday(t), hour(t), minute(t), second(t));
strcat(out, buf);
} else {
strcat_P(out, "000000F000000");
@ -108,8 +127,6 @@ char * if482Telegram(time_t t) {
}
// interrupt triggered routine
void sendIF482(time_t t) {
IF482.write(if482Telegram(t));
}
void sendIF482(time_t t) { IF482.write(if482Telegram(t)); }
#endif // HAS_IF482