[ create a new paste ] login | about

Link: http://codepad.org/0sEG1mmd    [ raw code | output | fork ]

C, pasted on Sep 28:
#define DeviceID '1'
void main(void) {
    SYSTEM_Initialize();
    INTERRUPT_GlobalInterruptEnable();
    INTERRUPT_PeripheralInterruptEnable();
    uint8_t InputCount = 0;
    bool DeviceSelectFlag = 0;

    while (1) {
        if (EUSART_is_rx_ready()) {
            uint8_t ReceiveValue = EUSART_Read();
            EUSART_Write(ReceiveValue);
            InputCount++;
            if (ReceiveValue == '\n') {
                InputCount = 0;
                DeviceSelectFlag = 1;
            } else {
                if (InputCount == 1) {
                    if (ReceiveValue != DeviceID) {
                        DeviceSelectFlag = 0;
                    }
                }
                if (InputCount == 2) {
                    if (ReceiveValue != ',') {
                        DeviceSelectFlag = 0;
                    }
                }
                if (InputCount == 3 && DeviceSelectFlag == 1) {
                    printf("deviceID 1 data1 Recive\n");
                }
                if (InputCount == 4 && DeviceSelectFlag == 1) {
                    printf("deviceID 1 data2 Recive\n");
                }
                if (InputCount == 5 && DeviceSelectFlag == 1) {
                    printf("deviceID 1 data3 Recive\n");
                }
            }
        }
    }
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
In function 'main':
Line 6: error: 'uint8_t' undeclared (first use in this function)
Line 6: error: (Each undeclared identifier is reported only once
Line 6: error: for each function it appears in.)
Line 6: error: expected ';' before 'InputCount'
Line 7: error: 'bool' undeclared (first use in this function)
Line 7: error: expected ';' before 'DeviceSelectFlag'
Line 11: error: expected ';' before 'ReceiveValue'
Line 12: error: 'ReceiveValue' undeclared (first use in this function)
Line 13: error: 'InputCount' undeclared (first use in this function)
Line 16: error: 'DeviceSelectFlag' undeclared (first use in this function)
Line 2: warning: return type of 'main' is not 'int'


Create a new paste based on this one


Comments: