Full Duplex Serial Com with Propeller C and Matlab Issues
cdkappy
Posts: 4
Hello, I am somewhat new to serial communications but did go through the half and full duplex serial lessons in Simple IDE. I am trying to use the Propeller Quick Start board as a data acquisition device and Matlab on my PC as the interface device and place to store the files. In my setup, Matlab needs to send some basic config (sample rate, channels to collect...) info and the start/stop flag. Using full duplex communication seemed to be the way to go. I have successfully connected and sent data both ways. My problem occurs when I use certain combinations of commands. The relevant part of my code looks like this:
// Matlab = fdserial_open(31, 30, 0, 115200); //
// int GetStart = fdserial_rxChar(Matlab); [/B] // This line receives a numeric 1 from Matlab. It comes out in ASCII format which I can handle
// dprint(Matlab, "%d\n", GetStart); // I'll get back a 49 in Matlab which is not a big deal for what I using this for
// int CollectInterval = readDec(Matlab); // This line is supposed to get the sample rate in ms from Matlab (no decimal, just an integer) I used this function since I needed to read more than one byte and have it formatted as a number I can directly use. However, this line seems to mess up the communications. Not sure but when I comment it out and run with a value of CollectInterval set in the Propeller program the rest of the program function properly.
// dprint(Matlab, "%d\n",CollectInterval); // Properly sends value to Matlab when set in the Propeller program.
// while(1)
// {
// dprint(Matlab, "%.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n", Temp[0],Temp[1],Temp[2],Temp[3],Temp[4],Temp[5],Temp[6],Temp[7]);
// } // This sends data beautifully to the Matlab object. when the I don't use readDec(Matlab) function. Is this function not usable when in full serial duplex??
This next question is broad and maybe a cry for help but is there a better way to read in data in full duplex mode other than one byte at a time?
Thanks!
// Matlab = fdserial_open(31, 30, 0, 115200); //
// int GetStart = fdserial_rxChar(Matlab); [/B] // This line receives a numeric 1 from Matlab. It comes out in ASCII format which I can handle
// dprint(Matlab, "%d\n", GetStart); // I'll get back a 49 in Matlab which is not a big deal for what I using this for
// int CollectInterval = readDec(Matlab); // This line is supposed to get the sample rate in ms from Matlab (no decimal, just an integer) I used this function since I needed to read more than one byte and have it formatted as a number I can directly use. However, this line seems to mess up the communications. Not sure but when I comment it out and run with a value of CollectInterval set in the Propeller program the rest of the program function properly.
// dprint(Matlab, "%d\n",CollectInterval); // Properly sends value to Matlab when set in the Propeller program.
// while(1)
// {
// dprint(Matlab, "%.1f %.1f %.1f %.1f %.1f %.1f %.1f %.1f\n", Temp[0],Temp[1],Temp[2],Temp[3],Temp[4],Temp[5],Temp[6],Temp[7]);
// } // This sends data beautifully to the Matlab object. when the I don't use readDec(Matlab) function. Is this function not usable when in full serial duplex??
This next question is broad and maybe a cry for help but is there a better way to read in data in full duplex mode other than one byte at a time?
Thanks!
Comments