Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 7 months ago.
Error at line 35 ("Expression must be an Ivalue or function designator")
First off let me explain that I am a complete neophyte here.
And also thanks to Christian and Rainer for getting me this far.
My day job is as a consultant for projects ranging from Architectural Engineering to product development, management, etc. (Architect, Industrial, and TV/Film degrees)
The purpose of the code is to eventually trigger relays, which I am using LED2-4 in place of.
In operation function1 will clear all relays (logic1 or float) function2 - functionx will turn on the relay (logic 0)
Each function is an 8byte word that always start 0xF9, 0xFF; and end 0x00 Communication is via RS-232 or 485 (RS-232 seems to work fine)
Also LED1 will flash if Uart active. (I probably don't need this if the MBED LED does the same thing.
I am hung up on an error at line 35 ("Expression must be an Ivalue or function designator") I am also unsure of the placement for "int i = 0"
- include "mbed.h"
char buffer[8]; char function1[] = {0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xA1, 0xC2, 0x00}; Array for function char function2[] = {0xF9, 0xFF, 0xBF, 0xFF, 0xFF, 0xA1, 0x42, 0x00}; char function3[] = {0xF9, 0xFF, 0x7F, 0xFF, 0xFF, 0xA1, 0xC2, 0x00}; char function4[] = {0xF9, 0xFF, 0xE8, 0x99, 0xDF, 0xA1, 0x66, 0x00};
int i = 0;
Serial pc(USBTX, USBRX); Serial uart(p9, p10); Connect TX to RX (p9 to p10) void uart_interrupt() { if(uart.readable()) { check availability buffer[i] = uart.getc(); copy the serial input to buffer i++; increment buffer value } }
DigitalOut uart_activity(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); assign led function
int main() { uart.baud(2400);
uart.attach(&uart_interrupt(), Serial::RxIrq); while(true) { if(!memcmp(buffer, function1, 8)) { led4 = 1; i = 0; doing this prevents buffer overflow, i.e. you reset i, to point to buffer[0] again. } if(buffer == function1) led4 = 1; led 1 on if function1
while(1) { if(pc.readable()) { uart.putc(pc.getc()); pc_activity = !pc_activity } uart_activity = 0; turn off rx led if(uart.readable()) { pc.putc(uart.getc()); uart_activity = !uart_activity; wait(0.01); Turn on LED 1 when data recieved void Tx_interrupt(); void Rx_interrupt(); void send_line(); void read_line(); } }
} }