Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: max32630fthr USBDevice
Revision 11:72363a906638, committed 2020-09-04
- Comitter:
- tlyp
- Date:
- Fri Sep 04 18:02:33 2020 +0000
- Parent:
- 10:aec2b8ba06a0
- Commit message:
- Initial Commit
Changed in this revision
diff -r aec2b8ba06a0 -r 72363a906638 ForwardErrCorr.cpp --- a/ForwardErrCorr.cpp Fri Aug 14 19:18:42 2020 +0000 +++ b/ForwardErrCorr.cpp Fri Sep 04 18:02:33 2020 +0000 @@ -1,30 +1,69 @@ +/******************************************************************************* +* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +*/ + #include "ForwardErrCorr.h" - -Translator::Translator(RawSerial &uart2, char *TransTable): -m_uart(uart2),m_TransTable(TransTable) +Translator::Translator(char *SymmetricKey, char *TransTable): +m_SymmetricKey(SymmetricKey),m_TransTable(TransTable) { } +//****************************************************************************** Translator::~Translator(void){ - } +} -uint32_t Translator::Reconstruct(char *tes, uint16_t *Output){ +//****************************************************************************** +uint32_t Translator::Decrypt(char *tes, uint16_t *Output){ int8_t ValOut,ValIn; - uint8_t count = 0; - int factor = 0; + int key = 0; + Output[0] = 0; + printf("Recieved Data -> Decrypted Data:\r\n"); for(int i = 2;i<10;i++){ ValIn = tes[i]; - ValOut = 0; + ValIn = ValIn ^ m_SymmetricKey[key]; //Unencrypt data + printf("%c -> %i\r\n",tes[i],ValIn); + key++; + ValOut = 5; for (int j=0;j<4;j++){ if (ValIn == m_TransTable[j]){ ValOut = j; } } - if (ValOut == 0){ + if (ValOut == 5){ ValOut = ChkHam(ValIn); } if (ValOut == 4){ + printf("Transmission error -- Hamming Distance Collision\r\n"); return (1); } Output[0] = (Output[0] << 2) + ValOut; @@ -32,8 +71,9 @@ return(0); } -int Translator::ChkHam(char test){ - char trial = test & 0x1F; +//****************************************************************************** +int Translator::ChkHam(char ChkVal){ + char trial = ChkVal & 0x1F; bool dupe = 0; int index, temp; int min = 5; @@ -59,35 +99,46 @@ } } - - -int Translator::HamDist(char test, char table){ +//****************************************************************************** +int Translator::HamDist(char ChkVal, char TableVal){ int count=0; char tes1,tes2; for (int j =0;j<5;j++){ - tes1 = test >> j; - tes2 = table >> j; + tes1 = ChkVal >> j; + tes2 = TableVal >> j; char temp = tes1 ^ tes2; count += temp&1; } return (count); } - -uint32_t Translator::TranslatetoTable(uint16_t tempData){ +//****************************************************************************** +uint32_t Translator::Encrypt(uint16_t tempData,char *EncryptedData){ char data; + int z=0; + printf("FEC Encoded Data:\r\n"); for (int i=14;i>=0;i-=2){ data = ((tempData >> i)&0x03); - m_uart.putc(m_TransTable[data]); + data = m_TransTable[data]; + printf("%d ",data); + data = (data ^ m_SymmetricKey[z]); + EncryptedData[z]=data; + z++; + } + printf("\r\n"); + return(0); +} + +//****************************************************************************** +uint32_t Translator::Encrypt(char tempData, char *EncryptedData){ + char data; + int z =0; + for (int i=6;i>=0;i-=2){ + data = ((tempData >> i)&0x03); + data = m_TransTable[data]; + data = (data ^ m_SymmetricKey[z]); + EncryptedData[z] = data; + z++; } return(0); } - -uint32_t Translator::TranslatetoTable(char tempData){ - char data; - for (int i=6;i>=0;i-=2){ - data = ((tempData >> i)&0x03); - m_uart.putc(m_TransTable[data]); - } - return(0); -}
diff -r aec2b8ba06a0 -r 72363a906638 ForwardErrCorr.h --- a/ForwardErrCorr.h Fri Aug 14 19:18:42 2020 +0000 +++ b/ForwardErrCorr.h Fri Sep 04 18:02:33 2020 +0000 @@ -1,4 +1,58 @@ +/******************************************************************************* +* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +*/ +/** + * @brief Library for the MAX30208\n + * + * @code + * #include "mbed.h" + * #include "max32630fthr.h" + * #include "ForwardErrCorr.h" + * + * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); + * + * #define SymmetricKey "PaSsWoRd" + * char TransTable[] = {0x1F,0x18,0x06,0x01}; + * + * //Create translator instance + * Translator transTx(SymmetricKey, TransTable); //Constructor takes 7-bit slave adrs + * + * int main(void) + * { + * //use Encoder + * } + * @endcode + */ #ifndef __FORWARDERRCORR_H_ #define __FORWARDERRCORR_H_ @@ -8,25 +62,61 @@ class Translator{ public: - Translator(RawSerial &uart2, char *TransTable); - + + /** + * @brief Constructor using reference to Symmetric key for encryption and FEC translation table + * @param SymmetricKey - Symmetric Key used by tranmsitter and reciever to encrypt/decrypt transmitted messages + * @param TransTable - Translation table used for Forward Error Correction code + */ + Translator(char *SymmetricKey, char *TransTable); + + /** + * @brief De-constructor + */ ~Translator(void); - - uint32_t TranslatetoTable(uint16_t tempData); + + /** + * @brief Takes 2 byte data packet, converts to FEC 8 byte packet, and encrypts each byte + * @param tempData[IN] - 2 byte data that needs to be prepared for transmission + * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stored, ready to send + * @return 0 on success, 1 on failure + */ + uint32_t Encrypt(uint16_t tempData,char *EncryptedData); - uint32_t TranslatetoTable(char tempData); - - int HamDist(char test, char table); + /** + * @brief Takes 1 byte data packet, converts to FEC 8 byte packet, and encrypts each byte + * @param tempData[IN] - 2 byte data that needs to be prepared for transmission + * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stroed, ready to send + * @return 0 on success, 1 on failure + */ + uint32_t Encrypt(char tempData, char*EncryptedData); - int ChkHam(char test); + /** + * @brief Calculates the hamming disatnce between 2 bytes + * @param ChkVal[IN] - Byte to use in hamming distance check + * @param TableVal[IN] - Byte to use in hamming distance check + * @return Hamming distance between the two provided bytes (range of 0-8) + */ + int HamDist(char ChkVal, char TableVal); - uint32_t Reconstruct(char *tes, uint16_t *Output); + /** + * @brief Converts 1 byte of FEC code back to original 2 bit data + * @param ChkVal - 1 byte of encoded data that needs to be decoded + * @return 0,1,2,3 to indicate correctly decoded table index, 4 on transmission error + */ + int ChkHam(char ChkVal); + + /** + * @brief Function that takes encrypted FEC data and converts it back to 2 byte data + * @param[IN] EncryptedData - Array of the encrypted data + * @param[OUT] Output - 16 bit data returned after decryption + * @return 0 on sucess, 1 on failure + */ + uint32_t Decrypt(char *EncryptedData, uint16_t *Output); private: - RawSerial &m_uart; - - char *m_TransTable; + char *m_TransTable, *m_SymmetricKey; }; #endif /* __ForwardErrCorr_H_*/ \ No newline at end of file
diff -r aec2b8ba06a0 -r 72363a906638 MAX30208.cpp --- a/MAX30208.cpp Fri Aug 14 19:18:42 2020 +0000 +++ b/MAX30208.cpp Fri Sep 04 18:02:33 2020 +0000 @@ -1,35 +1,35 @@ /******************************************************************************* - * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Maxim Integrated - * Products, Inc. shall not be used except as stated in the Maxim Integrated - * Products, Inc. Branding Policy. - * - * The mere transfer of this software does not imply any licenses - * of trade secrets, proprietary technology, copyrights, patents, - * trademarks, maskwork rights, or any other form of intellectual - * property whatsoever. Maxim Integrated Products, Inc. retains all - * ownership rights. - ******************************************************************************* - */ +* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +*/ #include "MAX30208.h"
diff -r aec2b8ba06a0 -r 72363a906638 MAX30208.h --- a/MAX30208.h Fri Aug 14 19:18:42 2020 +0000 +++ b/MAX30208.h Fri Sep 04 18:02:33 2020 +0000 @@ -1,35 +1,35 @@ /******************************************************************************* - * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Maxim Integrated - * Products, Inc. shall not be used except as stated in the Maxim Integrated - * Products, Inc. Branding Policy. - * - * The mere transfer of this software does not imply any licenses - * of trade secrets, proprietary technology, copyrights, patents, - * trademarks, maskwork rights, or any other form of intellectual - * property whatsoever. Maxim Integrated Products, Inc. retains all - * ownership rights. - ******************************************************************************* - */ +* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +*/ #ifndef __MAX30208_H_ #define __MAX30208_H_
diff -r aec2b8ba06a0 -r 72363a906638 main.cpp --- a/main.cpp Fri Aug 14 19:18:42 2020 +0000 +++ b/main.cpp Fri Sep 04 18:02:33 2020 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. +* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,7 +29,23 @@ * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. ******************************************************************************* + +This is code for the MAX1473 RF Receiver circuit. This program will capture, +translate, and unencrypt messages received using the ForwardErrCorr.h format. +The example uses MAX30208 temperature data as an example. + +Hardware Setup and connections: + + MAX32630FTHR-> MAX1473 Ev-Kit + + 3.3V -> VDD + GND -> GND + P3_0 -> DATA_OUT + 1.8V -> 200KOhm -> TP2 + +******************************************************************************* */ + #include "mbed.h" #include "max32630fthr.h" #include "USBSerial.h" @@ -38,16 +54,18 @@ MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); -// Hardware serial port over DAPLink -Serial daplink(USBTX, USBRX); // Use USB debug probe for serial link -Serial uart(P2_1, P2_0); -RawSerial uart2(P3_1,P3_0);//tx,rx +//Read UART Data +RawSerial uart(P3_1,P3_0);//tx,rx I2C i2c(P3_4, P3_5); //sda,scl +//Temperature Sensor Object to convert raw temp data to degress C MAX30208 TempSensor(i2c, 0x50); //Constructor takes 7-bit slave adrs -char TransTable[] = {0x1F,0x18,0x06,0x01}; -Translator transRx(uart2, TransTable); + + +char TransTable[] = {0x1F,0x18,0x06,0x01}; //Used to translate data for FEC -- Make sure it is identical to transmitter +#define SymmetricKey "RfIsCoOl" //Set Symmetric Key here -- Make sure it is identical to transmitter +Translator transRx(SymmetricKey, TransTable); // Virtual serial port over USB USBSerial microUSB; @@ -58,76 +76,106 @@ DigitalIn TakeData2(P5_5); DigitalIn sw1(SW1); -void buildArray(int j, char *input,char *output){ +//***************************************************************************** +int buildArray(int j, char *input,char *output){ int i = j+1; int k = 0; - while(input[i] != 'c'){ + while(input[i] != 'c' && i < 50){ output[k] = input[i]; i++; k++; } + if(input[i] == 'c'){ + return(0); + } + return(1); } char dataIn[50]; +//***************************************************************************** void SerialCallback(){ - //Timer timer; - //timer.start(); - wait_ms(1); - int i = strlen(dataIn); + int i = strlen(dataIn); //Make sure not to overflow the storage if (i >= 50){ i = 0; } - while(uart2.readable()){ - dataIn[i] = uart2.getc(); + + //Read Data while it is available on RX pin + while(uart.readable()){ + dataIn[i] = uart.getc(); i++; } - //wait_ms(10); } -// main() runs in its own thread in the OS -// (note the calls to Thread::wait below for delays) +//***************************************************************************** + int main() { + //Turn on LEDS rLED = LED_ON; gLED = LED_ON; bLED = LED_OFF; - uart2.baud(9600); - uart2.attach(&SerialCallback); rLED = LED_OFF; - char dataOut[50]; - uint16_t output[10]; + + //Uart Settings + uart.baud(9600); //Set baud to 9600 + uart.attach(&SerialCallback); //Set intterupt function to read uart data from reciever + + char dataOut[50]; //Hold incoming messages + uint16_t output[5]; //Hold packet information after decoding + printf("Program Begin\r\n"); + + //Runs continuously after initial setup while(1) { - if (strlen(dataIn) >= 12){ - int j = 0; - while(dataIn[j] != 'b' && j < 30){ - j++; + if (strlen(dataIn) >= 14){ //Wait until at least 1 packet has been recorded + wait_ms(50); //Short pause to ensure interrupt function has completed data read + + //Find the start of the packet + int start = 0; + while(dataIn[j] != 'b' && j < 34){ + start++; } - if (dataIn[j] == 'b'){ - microUSB.printf("\r\n\r\n\r\n\r\n"); - buildArray(j,dataIn,dataOut); - microUSB.printf("\r\n"); - if (transRx.Reconstruct(dataOut,output) == 1){ - microUSB.printf("Error reconstructing\r\n"); + + //Check that starting character was found + if (dataIn[start] == 'b'){ + printf("Building Array\r\n"); + + //Build array that holds only one data packet + if (buildArray(start,dataIn,dataOut)==0){ + microUSB.printf("\r\n"); + + //Decrypt the packet + if (transRx.Decrypt(dataOut,output) == 1){ + printf("Error reconstructing\r\n"); + }//if + + //Print out the data value, Device ID, Device Type, and Temperature + printf("Decoded Data Value: %i\r\n",output[0]); + printf("Device Type: %c\r\n", dataIn[j+1]); + printf("Device ID: %i\r\n", dataIn[j+2]); + float clesius = TempSensor.toCelsius(output[0]); + float fare = TempSensor.toFahrenheit(clesius); + printf("Temperature: %f F\r\n",fare); + printf("Temperature: %f C",clesius); + printf("\r\n\r\n"); + }//if + else{ + + //If the end character cannot be found, clear the data and listen for new messages + printf("error building array\r\n"); } - //Print out the Device Type, ID, and Temperature - microUSB.printf("Device Type: %c\r\n", dataIn[j+1]); - microUSB.printf("Device ID: %c\r\n", dataIn[j+2]); - - //uint16_t temp1 = (output[0]<<8); - //uint16_t delivery = (temp1 + output[1]); - //float clesius = TempSensor.toCelsius(output[0]); - //float fare = TempSensor.toFahrenheit(clesius); - microUSB.printf("Data read %u\r\n",output[0]); + //Clear the data array after the data has been decrypted for (int i = 0;i<sizeof(dataIn);i++){ dataIn[i] = 0; - } - } + }//for + }//if + + //If start character cannot be found, clear array before listening for more data else{ for (int i = 0;i<sizeof(dataIn);i++){ dataIn[i] = 0; - } - } - } + }//for + }//else + }//if } }