Getting data from sensor

You have sufficient information now to answer it yourself!

This is standard, basic, textbook ‘C’ stuff - there is no magic, and nothing special or peculiar to OPen-AT:

char comando[]="OPEN<LF><CR>";

That is just a standard ‘C’ string, isn’t it?
It contains the word “OPEN”, followed by a less-than symbol, etc.
There is nothing special or peculiar to Open-AT here.

char comando[]="OPEN\n";

Again, that is just a standard ‘C’ string, isn’t it?
It contains the word “OPEN”, followed by the standard ‘C’ \n escape sequence.
The only possible dependency on Open-AT is whether the \n might get translated - and I have already answered that question!

snoke
Any way your write/send it, to send the same than an “Enter” to a PC: Usually in Windows you need \n\r, and in Linux \n is enough.
Anyway, it depends on what you mean with “station” and the reciving program on it.

Actually, it’s \r\n; ie, CRLF - in that order.

Windows requires CRLF as the end-of-line sequence; that’s why some ‘C’ compilers will translate \n in a ‘C’ string to CRLF in the actual output stream (strictly, it’s the runtime library that does the translation - not the compiler).

eg, see: viewtopic.php?f=38&t=3024&p=11103&hilit=translation#p11153

I have already noted that adl_fcmSendData does not do any translation (which is obvious, if you think about it - otherwies it could not be used for binary data!)

Note that there is no direct relationship between the ‘Enter’ key on a PC keyboard and any sequence of characters that may or may not be transmitted on the PC’s COM port!

It depends entirely upon the application.

eg, Hypoterninal can be configured to send either CR or CRLF when the ‘Enter’ key is pressed…

When i connect to my station with hyperterminal i type “open” + [enter] and my station response:

APPLICATION MODE STARTED

X100>

My question is… I need simulate response of my station after send: char comando[]=“OPEN\n”;?

After enter in the system of station i need send one more command, and this command return data, and i want send this data to my webserver…

I can send char comando[]=“OPEN\nSHOW DATA\n”; ? Or i need send two in separate commands?

Please help

That depends entirely upon the “station” and has nothing at all to do with Open-AT.

Your Open-AT application must do whatever the “station” requires.
To find out what the “station” requires, you must study its documentation and/or speak to the manuafacturer.

However, at a guess, I would say that the “X100>” looks very much like a prompt, doesn’t it?

And the reason for any system to give a prompt is to indicate when it is ready to receive, isn’t it?

Therefore you should assume that, before the prompt, the “station” is not ready to receive - don’t you think?

You do not understand, so I reach x100> I send the command OPEN, after having sent the OPEN command the station returns

APPLICATION MODE STARTED

X100>

But i think my app not send correct command to my station because she not response anything.

If when i connected to my station with hyperterminal i send OPEN [enter] and my station response:

APPLICATION MODE STARTED

X100>

When my app send OPEN\n to FCM my station should return:

APPLICATION MODE STARTED

X100>

:frowning:

So what, exactly, is the correct command?

Do not guess - consult the documentation for the “station”.

If the documentation is not clear, then ask the manufacturer of the “station”.

And have you verified that this is the correct command?

And that you are sending it at the correct speed, with the correct serial port settings, using a correctly-wired cable with all the correct handshaking lines, etc…

Yes “OPEN” is a correct command, was one of the programmers of station told me…

The station only work in 9600 and i set speed of my modem in 9600 (AT+IPR=9600 + AT&W), i dont know what is wrong… :frowning:

But that’s not the complete command, is it?

You also send \n, don’t you?

Have you verified that this is correct?

And what about all the other things I mentioned?

You need to think carefully, and check every detail!

Have you monitored the signal at the “station’s” input to verify that the command is actually reaching the “station” ?

Have you monitored the signal at the “station’s” output to check if it is transmitting anything at all?

How i can do it?

Yes OPEN only open de system, if i need get data i need send SHOW DATA. And \n is correct.

i think the cable is correct, because when i connected directly to station with PC and hyperterminal, work correctly, but i have a question, is a necessary config in my app the settings of port? The speed i config with hyperterminal and i set at&w to save, but how i can config data bits, party, stop bits and flow control?

Thanks for your help!!

Do you have an oscilloscope?

If not, use the Rx line of a PC’s COM port…

No, it doesn’t!

Think!!

If you just type “OPEN” in Hypoterminal, nothing happens - does it?

Nothing happens until you press enter (or whatever) - does it?

So, your “station” not only requires the “OPEN” command; it also requires some command terminator.

Have you verified that you are sending the correct terminator?

That is not sufficient - you need to positively confirm that it is definitely correct!

But the PC has a different connector, doesn’t it?!

So you are not using the same cable, are you?!

If the app doesn’t do it, then you have to ensure that the modem is correctly configured “manually” before starting the app.

Do you have an oscilloscope?

If not, use the Rx line of a PC's COM port...

I will try!

No the cable not same, but the strange is when the modem is connected with serial cable to station and i execute one call data with hyperterminal to this modem and i put “OPEN + enter and SHOW DATA + enter” the station return a good data…

But i just want to have one modem to execute this process (get data)…

And if the same modem gets data when i calll data to it and i put the commands to get data… is strange why it doesnt get data when i run my app…

If i type only “OPEN” nothing happens, i need press the enter for receive:

APPLICATION MODE STARTED

X100>

Yes i configured manually before starting the app.

Very thank your help!!

I think the most likely cause is that your application is not sending the correct command termination character(s) - especially as you still haven’t confirmed that you really understand precisely what the correct command termination character (or characters) is (or are).

[size=150]You really need to confirm this explicitly from the “station” documentaion[/size] - or, failing that, by a specific enquiry to the manufacturer.

Another possibility is a timing issue - but you really need to confirm the command format first.

I confirmed with a programmer of station, this station no have a manual or a documentation…

I think the task of reading the data is not correct, please you can see if it is?

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

You are supposing the incoming data is ASCII, this probably is right if you comunicate with it via terminal. But suppose the length of the data is only 1, probably wrong.
And much important, THE INCOMING DATA IS NOT A STRING, you must convert it adding \0 at the end of the incoming data.
Review your C knowledge about strings, you will find more problems like this while you work through a terminal.

So, what is the correct command termination sequence? Tell us!

And have you verified that your application is, in fact, sending that correct command termination sequence?

what a pile of nasty, smelly stuff! :open_mouth:

As already noted, Data is not a string!

Therefore you cannot use Data as a string in a function like sprintf!

Absolutely!

Yet again your building is falling down because you have not laid good foundations with a solid understanding of the ‘C’ programming language!

You really should lay this aside for a while, and spend some time laying a good, solid foundation in the ‘C’ programming language!

The sequence command correct is “OPEN\nSHOW DATA\n” and my app send this:

char comando[]="OPEN\nSHOW DATA\n";


As already noted, Data is not a string!

Therefore you cannot use Data as a string in a function like sprintf!

Why not? What a function you suggest?

Open AT have a function to read the data coming from rs232?

Very Thanks you for your patience and assistance

In C, a string is always a char array finished with a \0 (0 in ascii). FCM data handler works with ascii and no-ascii strings, so what you need are waiting in you code is something like: [‘H’, ‘E’, ‘L’, ‘L’, ‘O’, ’ ', ‘W’, ‘O’, ‘R’, ‘L’, ‘D’, ‘\n’, ‘\0’]. Your station terminal doesn’t send you the ‘\0’. If you want to use the FCM incoming data as a string, you must add manually the \0.

In your own benefit: review your C knowledge about strings.

But, as already noted, \n could produce just LF in some systems (including Open-AT), but could produce CRLF in others.

Have you actually confirmed with your programmer friend exactly what termination character(s) are required?

Note that ‘Data’ here refers to the ‘Data’ parameter in the FCM Data Handler

Think about it: what is the definition of a string in the ‘C’ programming language…?

Yes - FCM can do precisely that! But it does assume that you are proficient in the ‘C’ programming language!