@@ -85,21 +85,24 @@ namespace pocsag {
85
85
void Decoder::flushMessage () {
86
86
if (!msg.empty ()) {
87
87
88
- // Unpack bits
89
- std::string outStr = " " ;
90
-
91
- for (int i = 0 ; (i+7 ) <= msg.size (); i += 7 ) {
92
- uint8_t b0 = msg[i];
93
- uint8_t b1 = msg[i+1 ];
94
- uint8_t b2 = msg[i+2 ];
95
- uint8_t b3 = msg[i+3 ];
96
- uint8_t b4 = msg[i+4 ];
97
- uint8_t b5 = msg[i+5 ];
98
- uint8_t b6 = msg[i+6 ];
99
- outStr += (char )((b6<<6 ) | (b5<<5 ) | (b4<<4 ) | (b3<<3 ) | (b2<<2 ) | (b1<<1 ) | b0);
100
- }
101
-
102
- onMessage (addr, msgType, outStr);
88
+ // // Unpack bits
89
+ // std::string outStr = "";
90
+ // for (int i = 0; (i+7) <= msg.size(); i += 7) {
91
+ // uint8_t b0 = msg[i];
92
+ // uint8_t b1 = msg[i+1];
93
+ // uint8_t b2 = msg[i+2];
94
+ // uint8_t b3 = msg[i+3];
95
+ // uint8_t b4 = msg[i+4];
96
+ // uint8_t b5 = msg[i+5];
97
+ // uint8_t b6 = msg[i+6];
98
+ // outStr += (char)((b6<<6) | (b5<<5) | (b4<<4) | (b3<<3) | (b2<<2) | (b1<<1) | b0);
99
+ // }
100
+ // onMessage(addr, msgType, outStr);
101
+
102
+ // Send out message
103
+ onMessage (addr, msgType, msg);
104
+
105
+ // Reset state
103
106
msg.clear ();
104
107
leftInLast = 0 ;
105
108
}
@@ -165,30 +168,30 @@ namespace pocsag {
165
168
}
166
169
else if (msgType == MESSAGE_TYPE_ALPHANUMERIC) {
167
170
// Alpha messages pack 7bit characters in the entire codeword stream
168
- // int lasti;
169
- // for (int i = -leftInLast; i <= POCSAG_DATA_BITS_PER_CW-7; i += 7) {
170
- // // Read 7 bits
171
- // char c = 0;
172
- // if (i < 0) {
173
- // c = (lastMsgData & ((1 << (-i)) - 1)) << (7+i);
174
- // }
175
- // c |= (data >> (13 - i)) & 0b1111111;
176
-
177
- // // Save character
178
- // bitswapChar(c, c);
179
- // msg += c;
180
-
181
- // // Update last successful unpack
182
- // lasti = i;
183
- // }
184
-
185
- // Pack the bits backwards
186
- for (int i = 19 ; i >= 0 ; i--) {
187
- msg += (char )((data >> i) & 1 );
171
+ int lasti;
172
+ for (int i = -leftInLast; i <= POCSAG_DATA_BITS_PER_CW-7 ; i += 7 ) {
173
+ // Read 7 bits
174
+ char c = 0 ;
175
+ if (i < 0 ) {
176
+ c = (lastMsgData & ((1 << (-i)) - 1 )) << (7 +i);
177
+ }
178
+ c |= (data >> (13 - i)) & 0b1111111 ;
179
+
180
+ // Save character
181
+ bitswapChar (c, c);
182
+ msg += c;
183
+
184
+ // Update last successful unpack
185
+ lasti = i;
188
186
}
189
187
190
188
// Save how much is still left to read
191
- // leftInLast = 20 - (lasti + 7);
189
+ leftInLast = 20 - (lasti + 7 );
190
+
191
+ // // Pack the bits backwards
192
+ // for (int i = 19; i >= 0; i--) {
193
+ // msg += (char)((data >> i) & 1);
194
+ // }
192
195
}
193
196
194
197
// Save last data
0 commit comments