cof_serXread() is not reading/execting

Dear All,

Am trying to read a received msg from Port C and forward it to port B, it doesn’t work.

When I debugged the code, I found out that the code execution stops in the read function and goes back to the beginning of the loop but it doesnt proceed after

 wfd n = cof_serCread(msgData, strlen(msgData), 20);

Am I reading the array in a wrong way? Or maybe my timing is wrong? I tried to change the function parameters but with no use.

Your help is highly appreciated.

void main(){
int n;
static const char msgData[]= {"Hiiii am in serial c"};

brdInit(); 
serCopen(115200); 
serBopen(115200); 
loopinit();

while (1) {
   loophead();
   costate {  
        wfd n = cof_serCread(msgData, strlen(msgData), 20);
        wfd cof_serBwrite(msgData, n); 
  }
} 

serCclose(); 
serBclose(); 

}

Hello,
cof_serCread function reads specified number of bytes from serial port and stored it in a buffer.
Here there is no data available to read in serial port. So control goes back.

If you want to put some message buffer into serial port u can directly use command serXputs/write(see in help). After putting this data into serial port u can use read function to read data from serial port. ( read function/gets function to read serial data)

rgds
sarin

Dear All,

Am trying to read a received msg from Port C and forward it to port B, it doesn’t work.

When I debugged the code, I found out that the code execution stops in the read function and goes back to the beginning of the loop but it doesnt proceed after

 wfd n = cof_serCread(msgData, strlen(msgData), 20);

Am I reading the array in a wrong way? Or maybe my timing is wrong? I tried to change the function parameters but with no use.

Your help is highly appreciated.

void main(){
int n;
static const char msgData[]= {"Hiiii am in serial c"};

brdInit(); 
serCopen(115200); 
serBopen(115200); 
loopinit();

while (1) {
   loophead();
   costate {  
        wfd n = cof_serCread(msgData, strlen(msgData), 20);
        wfd cof_serBwrite(msgData, n); 
  }
} 

serCclose(); 
serBclose(); 

}

Thank you for your reply, i tried your suggestion but still it gives me the same problem i faced earlier. Am not sure if the serXputs works properly in my code!

Anyways, I removed all the cofunctions because i would like to get a better understanding of sending and recieving msgs to ports.

However, I still have a problem! I created a buffer that i store in it my msgData and pass it to port C then B. I get an empty buffer in port B which am sure that i dont pass an empty array.

Am new to embedded systems development, and your help is highly appreciated.

Please, do have look to the code.


 while (1)
   {
   	loophead();
   	costate
      {
            memcpy(buffer, msgData, msgData(string2));
            serCputs(buffer);
            memset(buffer, 0x00, sizeof(buffer));
            
            // n is 0 when i run the code
            n = serBread(buffer, sizeof(buffer),20);
            serBputs(buffer);
            printf("%s", buffer);

      }
    }



It WORKED :smiley:

Dynamic C is acting weird! It worked without changing a thing !!