Getting data from sensor

Just to labour that point in minute detail, note that \0 means a byte with the numeric value of zero; ie 0x00.

It is the ASCII NUL character - which is why the term “NUL-terminated” or “Null-terminated” is often used of ‘C’ strings.

You may also see “ASCIIz” written - where the ‘z’ is supposed to indicate the zero terminator at the end…

How often shall we repeat that until it sinks in?

fer.caballero thanks i will read about strings in C, but when i try my application in Terminal Emulator, when i write anything in window of Data: from Serial Link Manager displayed, from External COM displayed, what i wrote appears in data.txt on my server, for this is that i think a my app is read good from station, but she not sending nothing i think…

Where i can read the syntax of this function? In API documentation I did not find…

First time you work with OpenAT adl is difficult to find the description of handling functions, because in the documentation you have this description after a prototipe not a function name (f.ex.: typedef void (*function_type) (u8 parameter1, u16 *parameter2)). Take a look just after adl_fcmSubscribe.
Anyway, did you understand why it’s need to include a \0? Maybe we are getting lost in translation. sprintf, strcat, strcpy… and similar functions need to work that \0. You give them a pointer to the start of the string, and they know where is the end searching for that \0. So your sprintf would copy nothing or rubish, and the same about your strcat.

You should know by now that FCM is not a single function!

But it does provide all the facilities that you need!

There is a whole section on FCM - the Flow Control Manager - in the ADL User Guide.

I know but you can say what name of function to read data of rs232?

The function that receives incoming data is the Data Handler specified in the adl_fcmSubscribe call - You can give it whatever name you like!

In fact, you have given it the name “FcmDataHandler” - here:

bool FcmDataHandler (u16 DataLen, u8 * Data){
    char a[2];
    sprintf(a,"%s",(char *)Data);
    a[1]=0;
    strcat((char *)buffer,a);
    return TRUE;
}

That function is called whenever data is received on the subscribed Flow;

  • The ‘DataLen’ parameter tells you how many bytes of data were received;
  • The ‘Data’ parameter points to a buffer containing the received bytes

Note that FCM might collect a number of bytes and deliver them all togethger in a single call to the Data handler, or it might deliver them one-by-one in multiple calls - see the ADL User Guide for details.
Therefore your application must cope with a single “message” from the external device possibly being delivered in several separate calls to the Data Handler…

Hiya,

Can I suggest that you use the (Open Source) application RealTerm to work out exactly what is being sent back and forwards between the PC and your device. Hyperterm (while useful as it comes with windows) is not the worlds best terminal emulator for doing the sort of stuff you are trying to do.

Realterm lets you display inbound and outbound data in a number of different ways - ASCII, HEX bytes, HEX chars - or a number of combinations of these.

This will at least work out what characters your device is sending (including command terminations).

ciao, Dave

davidc very thanks!

I will try!!