Subversion Repositories HomeAutomation

Rev

Rev 2223 | Rev 2236 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 2223 Rev 2233
Line 54... Line 54...
54
#if (IR_PROTOCOLS_USE_NEXA1)
54
#if (IR_PROTOCOLS_USE_NEXA1)
55
    if (parseNexa1(buf, len, index, proto)==IR_OK) return IR_OK;
55
    if (parseNexa1(buf, len, index, proto)==IR_OK) return IR_OK;
56
#endif
56
#endif
57
#if (IR_PROTOCOLS_USE_VIKING)
57
#if (IR_PROTOCOLS_USE_VIKING)
58
    if (parseViking(buf, len, index, proto)==IR_OK) return IR_OK;
58
    if (parseViking(buf, len, index, proto)==IR_OK) return IR_OK;
-
 
59
#endif
-
 
60
#if (IR_PROTOCOLS_USE_VIKING_STEAK)
-
 
61
    if (parseVikingSteak(buf, len, index, proto)==IR_OK) return IR_OK;
59
#endif
62
#endif
60
    /* No protocol matched. */
63
    /* No protocol matched. */
61
    proto->protocol = IR_PROTO_UNKNOWN;
64
    proto->protocol = IR_PROTO_UNKNOWN;
62
    return IR_NOT_CORRECT_DATA;
65
    return IR_NOT_CORRECT_DATA;
63
}
66
}
Line 102... Line 105...
102
#if (IR_PROTOCOLS_USE_SIRC)
105
#if (IR_PROTOCOLS_USE_SIRC)
103
/**
106
/**
104
 * Test data on SIRC protocol, 12-bit version
107
 * Test data on SIRC protocol, 12-bit version
105
 * http://www.sbprojects.com/knowledge/ir/sirc.htm
108
 * http://www.sbprojects.com/knowledge/ir/sirc.htm
106
 * http://picprojects.org.uk/projects/sirc/sonysirc.pdf
109
 * http://picprojects.org.uk/projects/sirc/sonysirc.pdf
107
 *
110
 *
108
 * @param buf
111
 * @param buf
109
 *      Pointer to buffer to where to data to parse is stored
112
 *      Pointer to buffer to where to data to parse is stored
110
 * @param len
113
 * @param len
111
 *      Length of the data
114
 *      Length of the data
112
 * @param proto
115
 * @param proto
113
 *      Pointer to protocol information
116
 *      Pointer to protocol information
114
 * @return
117
 * @return
115
 *      IR_OK if data parsed successfully, one of several errormessages if not
118
 *      IR_OK if data parsed successfully, one of several errormessages if not
116
 */
119
 */
117
int8_t parseSIRC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
120
int8_t parseSIRC(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
118
    /* parse buf[], max is len */
121
    /* parse buf[], max is len */
119
 
122
 
120
    /* check if we have correct amount of data.
123
    /* check if we have correct amount of data.
121
           supporting two versions of SIRC:
124
           supporting two versions of SIRC:
122
           12 bit = 25, 15 bit = 31
125
           12 bit = 25, 15 bit = 31
123
           there is also a 20 bit protocol, but we don't support it
126
           there is also a 20 bit protocol, but we don't support it
124
         */
127
         */
Line 126... Line 129...
126
        return IR_NOT_CORRECT_DATA;
129
        return IR_NOT_CORRECT_DATA;
127
    }
130
    }
128
   
131
   
129
    /* check startbit */
132
    /* check startbit */
130
    if (buf[0] > IR_SIRC_ST_BIT + IR_SIRC_ST_BIT/IR_SIRC_TOL_DIV || buf[0] < IR_SIRC_ST_BIT - IR_SIRC_ST_BIT/IR_SIRC_TOL_DIV) {
133
    if (buf[0] > IR_SIRC_ST_BIT + IR_SIRC_ST_BIT/IR_SIRC_TOL_DIV || buf[0] < IR_SIRC_ST_BIT - IR_SIRC_ST_BIT/IR_SIRC_TOL_DIV) {
131
        return IR_NOT_CORRECT_DATA;
134
        return IR_NOT_CORRECT_DATA;
132
    }
135
    }
133
   
136
   
134
    uint16_t rawbits=0;
137
    uint16_t rawbits=0;
135
   
138
   
136
    for (uint8_t i = 1; i < len; i++) {
139
    for (uint8_t i = 1; i < len; i++) {
137
        if ((i&1) == 1) {       /* if odd, ir-pause */
140
        if ((i&1) == 1) {       /* if odd, ir-pause */
138
            /* check length of pause between bits */
141
            /* check length of pause between bits */
139
            if (buf[i] > IR_SIRC_LOW + IR_SIRC_LOW/IR_SIRC_TOL_DIV || buf[i] < IR_SIRC_LOW - IR_SIRC_LOW/IR_SIRC_TOL_DIV) {
142
            if (buf[i] > IR_SIRC_LOW + IR_SIRC_LOW/IR_SIRC_TOL_DIV || buf[i] < IR_SIRC_LOW - IR_SIRC_LOW/IR_SIRC_TOL_DIV) {
140
                return IR_NOT_CORRECT_DATA;
143
                return IR_NOT_CORRECT_DATA;
141
            }
144
            }
142
        } else {            /* if even, ir-bit */
145
        } else {            /* if even, ir-bit */
143
            if (buf[i] > IR_SIRC_HIGH_ONE - IR_SIRC_HIGH_ONE/IR_SIRC_TOL_DIV && buf[i] < IR_SIRC_HIGH_ONE + IR_SIRC_HIGH_ONE/IR_SIRC_TOL_DIV) {
146
            if (buf[i] > IR_SIRC_HIGH_ONE - IR_SIRC_HIGH_ONE/IR_SIRC_TOL_DIV && buf[i] < IR_SIRC_HIGH_ONE + IR_SIRC_HIGH_ONE/IR_SIRC_TOL_DIV) {
144
                /* write a one */
147
                /* write a one */
145
                rawbits |= 1<<((i-2)>>1);
148
                rawbits |= 1<<((i-2)>>1);
146
            } else if (buf[i] > IR_SIRC_HIGH_ZERO - IR_SIRC_HIGH_ZERO/IR_SIRC_TOL_DIV && buf[i] < IR_SIRC_HIGH_ZERO + IR_SIRC_HIGH_ZERO/IR_SIRC_TOL_DIV) {
149
            } else if (buf[i] > IR_SIRC_HIGH_ZERO - IR_SIRC_HIGH_ZERO/IR_SIRC_TOL_DIV && buf[i] < IR_SIRC_HIGH_ZERO + IR_SIRC_HIGH_ZERO/IR_SIRC_TOL_DIV) {
147
                /* do nothing, a zero is already in rawbits */
150
                /* do nothing, a zero is already in rawbits */
148
            } else {
151
            } else {
149
                return IR_NOT_CORRECT_DATA;
152
                return IR_NOT_CORRECT_DATA;
150
            }
153
            }
151
        }
154
        }
152
    }
155
    }
153
   
156
   
154
    proto->protocol = IR_PROTO_SIRC;
157
    proto->protocol = IR_PROTO_SIRC;
155
    proto->timeout = IR_SIRC_TIMEOUT;
158
    proto->timeout = IR_SIRC_TIMEOUT;
156
    proto->data = rawbits;
159
    proto->data = rawbits;
157
   
160
   
158
    return IR_OK;
161
    return IR_OK;
159
}
162
}
160
#endif
163
#endif
161
 
164
 
162
/**
165
/**
Line 165... Line 168...
165
 *
168
 *
166
 * @param buf
169
 * @param buf
167
 *      Pointer to buffer to store the expanded data
170
 *      Pointer to buffer to store the expanded data
168
 * @param len
171
 * @param len
169
 *      Pointer to length of the data
172
 *      Pointer to length of the data
170
 * @param proto
173
 * @param proto
171
 *      Pointer to protocol information
174
 *      Pointer to protocol information
172
 * @return
175
 * @return
173
 *      IR_OK if data expanded successfully, one of several errormessages if not
176
 *      IR_OK if data expanded successfully, one of several errormessages if not
174
 */
177
 */
175
int8_t expandSIRC(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
178
int8_t expandSIRC(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
Line 203... Line 206...
203
 
206
 
204
 
207
 
205
#if (IR_PROTOCOLS_USE_RC5)
208
#if (IR_PROTOCOLS_USE_RC5)
206
/**
209
/**
207
 * Test data on RC5 protocol
210
 * Test data on RC5 protocol
208
 * http://www.sbprojects.com/knowledge/ir/rc5.htm
211
 * http://www.sbprojects.com/knowledge/ir/rc5.htm
209
 *
212
 *
210
 * @param buf
213
 * @param buf
211
 *      Pointer to buffer to where to data to parse is stored
214
 *      Pointer to buffer to where to data to parse is stored
212
 * @param len
215
 * @param len
213
 *      Length of the data
216
 *      Length of the data
214
 * @param proto
217
 * @param proto
215
 *      Pointer to protocol information
218
 *      Pointer to protocol information
216
 * @return
219
 * @return
217
 *      IR_OK if data parsed successfully, one of several errormessages if not
220
 *      IR_OK if data parsed successfully, one of several errormessages if not
218
 */
221
 */
219
int8_t parseRC5(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
222
int8_t parseRC5(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
220
    uint8_t halfbitscnt = 1;
223
    uint8_t halfbitscnt = 1;
221
    uint16_t rawbits = 0;
224
    uint16_t rawbits = 0;
222
   
225
   
Line 517... Line 520...
517
 
520
 
518
 
521
 
519
#if (IR_PROTOCOLS_USE_SAMSUNG)
522
#if (IR_PROTOCOLS_USE_SAMSUNG)
520
/**
523
/**
521
 * Test data on Samsung protocol
524
 * Test data on Samsung protocol
522
 * Very much like NEC, different start bit/pause lengths etc.
525
 * Very much like NEC, different start bit/pause lengths etc.
523
 * http://www.sbprojects.com/knowledge/ir/nec.htm
526
 * http://www.sbprojects.com/knowledge/ir/nec.htm
524
 *
527
 *
525
 * @param buf
528
 * @param buf
526
 *      Pointer to buffer to where to data to parse is stored
529
 *      Pointer to buffer to where to data to parse is stored
527
 * @param len
530
 * @param len
528
 *      Length of the data
531
 *      Length of the data
529
 * @param proto
532
 * @param proto
530
 *      Pointer to protocol information
533
 *      Pointer to protocol information
531
 * @return
534
 * @return
532
 *      IR_OK if data parsed successfully, one of several errormessages if not
535
 *      IR_OK if data parsed successfully, one of several errormessages if not
533
 */
536
 */
534
int8_t parseSamsung(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
537
int8_t parseSamsung(const uint16_t *buf, uint8_t len, Ir_Protocol_Data_t *proto) {
535
    /* parse buf[], max is len */
538
    /* parse buf[], max is len */
536
 
539
 
Line 840... Line 843...
840
    *len = 99;
843
    *len = 99;
841
   
844
   
842
    proto->modfreq=IR_PANA_F_MOD;
845
    proto->modfreq=IR_PANA_F_MOD;
843
    proto->timeout=IR_PANA_TIMEOUT;
846
    proto->timeout=IR_PANA_TIMEOUT;
844
    proto->repeats=IR_PANA_REPS;
847
    proto->repeats=IR_PANA_REPS;
845
    return IR_OK;
848
    return IR_OK;
846
}
849
}
847
 
850
 
848
#if (IR_PROTOCOLS_USE_SKY)
851
#if (IR_PROTOCOLS_USE_SKY)
849
/**
852
/**
850
 * Test data on Sky protocol
853
 * Test data on Sky protocol
851
 *
854
 *
Line 1154... Line 1157...
1154
        uint8_t i2;
1157
        uint8_t i2;
1155
#if IR_RX_CONTINUOUS_MODE==0
1158
#if IR_RX_CONTINUOUS_MODE==0
1156
        i2 = i;
1159
        i2 = i;
1157
#else
1160
#else
1158
        i2=index-(50-i);
1161
        i2=index-(50-i);
1159
        if (i2>index)
1162
        if (i2>index)
1160
            i2+=MAX_NR_TIMES;
1163
            i2+=MAX_NR_TIMES;
1161
#endif
1164
#endif
1162
        /* Check if '0' bit */
1165
        /* Check if '0' bit */
1163
        if (
1166
        if (
1164
            (buf[i2+0] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+0] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) &&
1167
            (buf[i2+0] > IR_NEXA1_SHORT - IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) && (buf[i2+0] < IR_NEXA1_SHORT + IR_NEXA1_SHORT/IR_NEXA1_TOL_DIV) &&
1165
            (buf[i2+1] > IR_NEXA1_LONG  - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+1] < IR_NEXA1_LONG  + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) &&
1168
            (buf[i2+1] > IR_NEXA1_LONG  - IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) && (buf[i2+1] < IR_NEXA1_LONG  + IR_NEXA1_LONG /IR_NEXA1_TOL_DIV) &&
Line 1191... Line 1194...
1191
        return IR_NOT_CORRECT_DATA;
1194
        return IR_NOT_CORRECT_DATA;
1192
    }
1195
    }
1193
   
1196
   
1194
    proto->protocol=IR_PROTO_NEXA1;
1197
    proto->protocol=IR_PROTO_NEXA1;
1195
    proto->timeout=IR_NEXA1_TIMEOUT;
1198
    proto->timeout=IR_NEXA1_TIMEOUT;
1196
    proto->data=rawbitsTemp;
1199
    proto->data=rawbitsTemp;
1197
    return IR_OK;
1200
    return IR_OK;
1198
}
1201
}
1199
 
1202
 
1200
#endif
1203
#endif
1201
 
1204
 
1202
/**
1205
/**
1203
 * Expand data from Nexa1 protocol
1206
 * Expand data from Nexa1 protocol
1204
 *
1207
 *
1205
 *
1208
 *
1206
 * @param buf
1209
 * @param buf
1207
 *      Pointer to buffer to store the expanded data
1210
 *      Pointer to buffer to store the expanded data
1208
 * @param len
1211
 * @param len
1209
 *      Pointer to length of the data
1212
 *      Pointer to length of the data
1210
 * @param proto
1213
 * @param proto
Line 1214... Line 1217...
1214
 */
1217
 */
1215
int8_t expandNexa1(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
1218
int8_t expandNexa1(uint16_t *buf, uint8_t *len, Ir_Protocol_Data_t *proto) {
1216
    uint64_t tempshift = proto->data;
1219
    uint64_t tempshift = proto->data;
1217
 
1220
 
1218
    /* 12 data bits + 1 stop bit */
1221
    /* 12 data bits + 1 stop bit */
1219
    *len = 49;
1222
    *len = 49;
1220
 
1223
 
1221
    /* encode data bits */
1224
    /* encode data bits */
1222
    for (uint8_t i = 0; i < 45; i += 4)
1225
    for (uint8_t i = 0; i < 45; i += 4)
1223
    {
1226
    {
1224
        if (tempshift & 1) {
1227
        if (tempshift & 1) {
1225
            /* encode 0 bit */
1228
            /* encode 0 bit */
1226
            buf[i+0] = IR_NEXA1_SHORT;
1229
            buf[i+0] = IR_NEXA1_SHORT;
1227
            buf[i+1] = IR_NEXA1_LONG;
1230
            buf[i+1] = IR_NEXA1_LONG;
1228
            buf[i+2] = IR_NEXA1_SHORT;
1231
            buf[i+2] = IR_NEXA1_SHORT;
1229
            buf[i+3] = IR_NEXA1_LONG;
1232
            buf[i+3] = IR_NEXA1_LONG;
1230
        } else {
1233
        } else {
1231
            /* encode X bit */
1234
            /* encode X bit */
Line 1233... Line 1236...
1233
            buf[i+1] = IR_NEXA1_LONG;
1236
            buf[i+1] = IR_NEXA1_LONG;
1234
            buf[i+2] = IR_NEXA1_LONG;
1237
            buf[i+2] = IR_NEXA1_LONG;
1235
            buf[i+3] = IR_NEXA1_SHORT;
1238
            buf[i+3] = IR_NEXA1_SHORT;
1236
        }
1239
        }
1237
        tempshift = tempshift>>1;
1240
        tempshift = tempshift>>1;
1238
    }
1241
    }
1239
 
1242
 
1240
    /* encode stop/sync bit */
1243
    /* encode stop/sync bit */
1241
    buf[48] = IR_NEXA1_SHORT;
1244
    buf[48] = IR_NEXA1_SHORT;
1242
   
1245
   
1243
    proto->modfreq = IR_NEXA1_F_MOD;
1246
    proto->modfreq = IR_NEXA1_F_MOD;
1244
    proto->timeout = IR_NEXA1_START/1000;
1247
    proto->timeout = IR_NEXA1_START/1000;
1245
    proto->repeats = IR_NEXA1_REPS;
1248
    proto->repeats = IR_NEXA1_REPS;
1246
    return IR_OK;  
1249
    return IR_OK;  
1247
}
1250
}
1248
 
1251
 
1249
 
1252
 
1250
#if (IR_PROTOCOLS_USE_VIKING)
1253
#if (IR_PROTOCOLS_USE_VIKING)
-
 
1254
/**
-
 
1255
 * Test data on Viking temperature sensor protocol
-
 
1256
 *
-
 
1257
 *
-
 
1258
 *
-
 
1259
 * @param buf
-
 
1260
 *      Pointer to buffer to where to data to parse is stored
-
 
1261
 * @param len
-
 
1262
 *      Length of the data
-
 
1263
 * @param proto
-
 
1264
 *      Pointer to protocol information
-
 
1265
 * @return
-
 
1266
 *      IR_OK if data parsed successfully, one of several errormessages if not
-
 
1267
 */
-
 
1268
 
-
 
1269
int8_t parseViking(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto)
-
 
1270
{
-
 
1271
#if IR_RX_CONTINUOUS_MODE==1
-
 
1272
    /* check if we have correct amount of data */
-
 
1273
    if (len < 90) {
-
 
1274
        return IR_NOT_CORRECT_DATA;
-
 
1275
    }
-
 
1276
    uint8_t i, i2;
-
 
1277
    uint64_t rawbitsTemp = 0;//0xffffffffffffffff;
-
 
1278
   
-
 
1279
    for (i = 90; i > 0; i--)
-
 
1280
    {
-
 
1281
        i2=index-i;
-
 
1282
        if (i2>index)
-
 
1283
            i2+=MAX_NR_TIMES;
-
 
1284
 
-
 
1285
        /* Check if correct amount of data have been received */
-
 
1286
        if ((i == 78) && (rawbitsTemp != 0b00001))
-
 
1287
            return IR_NOT_CORRECT_DATA;
-
 
1288
 
-
 
1289
        if ((i&1) == 0)
-
 
1290
        {       /* if even, no data */
-
 
1291
            if ((buf[i2] < IR_VIKING_LOW - IR_VIKING_LOW/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_LOW + IR_VIKING_LOW/IR_VIKING_TOL_DIV))
-
 
1292
            {
-
 
1293
                return IR_NOT_CORRECT_DATA;
-
 
1294
            }
-
 
1295
        }
-
 
1296
        else
-
 
1297
        {           /* if odd, data */
-
 
1298
            /* check length of transmit pulse */
-
 
1299
            if ((buf[i2] > IR_VIKING_HIGH_ONE - IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ONE + IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV))
-
 
1300
            {
-
 
1301
                /* write a one */
-
 
1302
                rawbitsTemp = rawbitsTemp<<1;
-
 
1303
                rawbitsTemp |= 1;
-
 
1304
            }
-
 
1305
            else if ((buf[i2] > IR_VIKING_HIGH_ZERO - IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ZERO + IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV))
-
 
1306
            {
-
 
1307
                /* do nothing, a zero is already in rawbits */
-
 
1308
                rawbitsTemp = rawbitsTemp<<1;
-
 
1309
            }
-
 
1310
            else
-
 
1311
            {
-
 
1312
                return IR_NOT_CORRECT_DATA;
-
 
1313
            }
-
 
1314
        }
-
 
1315
    }
-
 
1316
   
-
 
1317
    rawbitsTemp = ~rawbitsTemp;
-
 
1318
    rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF;
-
 
1319
   
-
 
1320
    proto->protocol=IR_PROTO_VIKING;
-
 
1321
    proto->timeout=0;
-
 
1322
    proto->data=rawbitsTemp;
-
 
1323
 
-
 
1324
    return IR_OK;
-
 
1325
#else
-
 
1326
    return IR_NOT_CORRECT_DATA;
-
 
1327
#endif
-
 
1328
}
-
 
1329
#endif
-
 
1330
 
-
 
1331
 
-
 
1332
#if (IR_PROTOCOLS_USE_VIKING_STEAK)
1251
/**
1333
/**
1252
 * Test data on Viking temperature sensor protocol
1334
 * Test data on Viking steak temperature sensor protocol
1253
 *
1335
 *
1254
 *
1336
 *
1255
 *
1337
 *
1256
 * @param buf
1338
 * @param buf
1257
 *      Pointer to buffer to where to data to parse is stored
1339
 *      Pointer to buffer to where to data to parse is stored
Line 1261... Line 1343...
1261
 *      Pointer to protocol information
1343
 *      Pointer to protocol information
1262
 * @return
1344
 * @return
1263
 *      IR_OK if data parsed successfully, one of several errormessages if not
1345
 *      IR_OK if data parsed successfully, one of several errormessages if not
1264
 */
1346
 */
1265
 
1347
 
1266
int8_t parseViking(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto)
1348
int8_t parseVikingSteak(const uint16_t *buf, uint8_t len, uint8_t index, Ir_Protocol_Data_t *proto)
1267
{
1349
{
1268
#if IR_RX_CONTINUOUS_MODE==1
1350
#if IR_RX_CONTINUOUS_MODE==1
1269
    /* check if we have correct amount of data */
1351
    /* check if we have correct amount of data */
1270
    if (len < 90) {
1352
    if (len < 76) {
1271
        return IR_NOT_CORRECT_DATA;
1353
        return IR_NOT_CORRECT_DATA;
1272
    }
1354
    }
1273
    uint8_t i, i2;
1355
    uint8_t i, i2;
1274
    uint64_t rawbitsTemp = 0;//0xffffffffffffffff;
1356
    uint64_t rawbitsTemp = 0;//0xffffffffffffffff;
1275
   
1357
   
-
 
1358
    /* Check start bit condition */
-
 
1359
    i2=index-76;
-
 
1360
    if (i2>index)
-
 
1361
        i2+=MAX_NR_TIMES;
-
 
1362
 
-
 
1363
    if ((buf[i2] < IR_VIKING_STEAK_LOW_ZERO - IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_LOW_ZERO + IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_TOL_DIV))
-
 
1364
    {
-
 
1365
        return IR_NOT_CORRECT_DATA;
-
 
1366
    }
-
 
1367
    i2++;
-
 
1368
    if (i2>index)
-
 
1369
        i2+=MAX_NR_TIMES;
-
 
1370
    if ((buf[i2] < IR_VIKING_STEAK_HIGH - IR_VIKING_STEAK_HIGH/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_HIGH + IR_VIKING_STEAK_HIGH/IR_VIKING_TOL_DIV))
-
 
1371
    {
-
 
1372
        return IR_NOT_CORRECT_DATA;
-
 
1373
    }
-
 
1374
    i2++;
-
 
1375
    if (i2>index)
-
 
1376
        i2+=MAX_NR_TIMES;
-
 
1377
    if ((buf[i2] < IR_VIKING_STEAK_LOW_START - IR_VIKING_STEAK_LOW_START/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_LOW_START + IR_VIKING_STEAK_LOW_START/IR_VIKING_TOL_DIV))
-
 
1378
    {
-
 
1379
        return IR_NOT_CORRECT_DATA;
-
 
1380
    }
-
 
1381
   
1276
    for (i = 90; i > 0; i--)
1382
    for (i = 73; i > 0; i--)
1277
    {
1383
    {
1278
        i2=index-i;
1384
        i2=index-i;
1279
        if (i2>index)
1385
        if (i2>index)
1280
            i2+=MAX_NR_TIMES;
1386
            i2+=MAX_NR_TIMES;
1281
 
1387
 
1282
        /* Check if correct amount of data have been received */
1388
        /* Check if correct amount of data have been received */
1283
        if ((i == 78) && (rawbitsTemp != 0b00001))
1389
        //if ((i == 78) && (rawbitsTemp != 0b00001))
1284
            return IR_NOT_CORRECT_DATA;
1390
        //  return IR_NOT_CORRECT_DATA;
1285
 
1391
 
1286
        if ((i&1) == 0)
1392
        if ((i&1) != 0)
1287
        {       /* if even, no data */
1393
        {       /* if odd, no data */
1288
            if ((buf[i2] < IR_VIKING_LOW - IR_VIKING_LOW/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_LOW + IR_VIKING_LOW/IR_VIKING_TOL_DIV))
1394
            if ((buf[i2] < IR_VIKING_STEAK_HIGH - IR_VIKING_STEAK_HIGH/IR_VIKING_TOL_DIV) || (buf[i2] > IR_VIKING_STEAK_HIGH + IR_VIKING_STEAK_HIGH/IR_VIKING_TOL_DIV))
1289
            {
1395
            {
1290
                return IR_NOT_CORRECT_DATA;
1396
                return IR_NOT_CORRECT_DATA;
1291
            }
1397
            }
1292
        }
1398
        }
1293
        else
1399
        else
1294
        {           /* if odd, data */
1400
        {           /* if even, data */
1295
            /* check length of transmit pulse */
1401
            /* check length of transmit pulse */
1296
            if ((buf[i2] > IR_VIKING_HIGH_ONE - IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ONE + IR_VIKING_HIGH_ONE/IR_VIKING_TOL_DIV))
1402
            if ((buf[i2] > IR_VIKING_STEAK_LOW_ONE - IR_VIKING_STEAK_LOW_ONE/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_STEAK_LOW_ONE + IR_VIKING_STEAK_LOW_ONE/IR_VIKING_TOL_DIV))
1297
            {
1403
            {
1298
                /* write a one */
1404
                /* write a one */
1299
                rawbitsTemp = rawbitsTemp<<1;
1405
                rawbitsTemp = rawbitsTemp<<1;
1300
                rawbitsTemp |= 1;
1406
                rawbitsTemp |= 1;
1301
            }
1407
            }
1302
            else if ((buf[i2] > IR_VIKING_HIGH_ZERO - IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_HIGH_ZERO + IR_VIKING_HIGH_ZERO/IR_VIKING_TOL_DIV))
1408
            else if ((buf[i2] > IR_VIKING_STEAK_LOW_ZERO - IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_TOL_DIV) && (buf[i2] < IR_VIKING_STEAK_LOW_ZERO + IR_VIKING_STEAK_LOW_ZERO/IR_VIKING_TOL_DIV))
1303
            {
1409
            {
1304
                /* do nothing, a zero is already in rawbits */
1410
                /* do nothing, a zero is already in rawbits */
1305
                rawbitsTemp = rawbitsTemp<<1;
1411
                rawbitsTemp = rawbitsTemp<<1;
1306
            }
1412
            }
1307
            else
1413
            else
1308
            {
1414
            {
1309
                return IR_NOT_CORRECT_DATA;
1415
                return IR_NOT_CORRECT_DATA;
1310
            }
1416
            }
1311
        }
1417
        }
1312
    }
1418
    }
-
 
1419
   
-
 
1420
    //rawbitsTemp = ~rawbitsTemp;
-
 
1421
    //rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF;
1313
   
1422
   
1314
    rawbitsTemp = ~rawbitsTemp;
-
 
1315
    rawbitsTemp = rawbitsTemp&0xFFFFFFFFFF;
-
 
1316
   
-
 
1317
    proto->protocol=IR_PROTO_VIKING;
1423
    proto->protocol=IR_PROTO_VIKING_STEAK;
1318
    proto->timeout=0;
1424
    proto->timeout=0;
1319
    proto->data=rawbitsTemp;
1425
    proto->data=rawbitsTemp;
1320
 
1426
 
1321
    return IR_OK;
1427
    return IR_OK;
1322
#else
1428
#else