Problem with parsing and regexp

18 Jun 2012

Hi mbedders :P

Im programming a quadcopter with the mbed as a cortex, one of the main topics of my project is to read the values of the IMU, getting strings by serial like this:

!!!AN0:-4,AN1:19,AN2:2,AN3:-2,AN4:29,AN5:100,RLL:-0.08,PCH:0.38,YAW:0.04,*

Im not sure, but I think that the way to read the values one by one and get it in individual variables is that:

while (imu->getc() != '!!!');
        imu->scanf("!!!AN0:%d,AN1:%d,AN2:%d,AN3:%d,AN4:%d,AN5:%d,RLL:%d,PCH:%d,YAW:%d,***", &an0, &an1, &an2, &an3, &an4, &an5, &rll, &pch, &yaw);

Before try blinded by ignorance to port that to the platform, I think that is a good idea to ask to the community.

Thanks so much by your attention :P

19 Jun 2012

Regular expression:

If there is a value that changes just put a .* WHERE THE VALUE CHANGES it would be best to store the string in a buffer first then print it out also.

19 Jun 2012

In my case, I only need to change the %d by *?

19 Jun 2012

Command: PeriodAstrix

Expression: .*

Expression Information: Contains any change in value

19 Jun 2012

Ok but I doubt about the type of the data, with * doesn't specify, how to? An example?

Regards

20 Jun 2012

!!!AN0:.*,AN1:.*,AN2:.*,AN3:.*,AN4:.*,AN5:.*,RLL:.*,PCH:.*,YAW:.* Go to my repository and look at my keyboard program, in the cpp you can see how to retreive values and split them up into individual values by using "," and using value[0] & value[1] to grab the value from that point, best thing is you can send as many as you want, this would be perfect for you.:)