 #define CN2_GETBYTE3_TIMEOUT 200 //is 40 oncalc
 #define CN2_GETBYTE5_TIMEOUT 900 //is 40 oncalc
 #define CN2_RECEIVEFRAMESTARTING_TIMEOUT 900000 //(55000-6000)/58 oncalc
+#define CN2_RECEIVEFRAMESTARTING_TIMEOUT_US 15000
 
 #endif
 
 #define CN2_MAX_FRAME_RETRIES 255
 
 #define WAITTIME(datasize) (17+(46*(datasize&0x7fff))/3)
+
+void resetLines();
+void mySerialEmptyBuf();
+unsigned int mySerialRead();
+static int cn2_send();
+static void cn2_receive();
+static uint16_t cn2_sendbyte(uint8_t);
+static uint16_t cn2_recbyte();
+static uint16_t cn2_search_FSM(uint16_t);
 
 #ifdef sparkcore
 TCPClient client;

    usbDeviceDisconnect();
    unsigned char i;
    i = 0;
    while(--i){             /* fake USB disconnect for > 250 ms */
        _delay_ms(1);
    }
    usbDeviceConnect();

        goto serialFlush;
        
        digitalWrite(CN2clock, LOW); // TEMPORARY - inhibit Cn2.2
        setRGBLED(ledr, LOW);
        setRGBLED(ledg, LOW);
        setRGBLED(ledb, HIGH);
      
        // Fetch the recipient ID
        for(i=0; i<5; i++) {
