HttpGet Error -40 - Not Enough Data Returned

This is my first attempt at HttpGet

  1. I have already successfully done a get from the command line to my ‘new’ device:

> httpget -r -S "*SRDC2/r"


> 0017.4

My OptoScript code is the following:

> stWeather_Send[0] = "*SRH2/r";
>   iWeather_Cmd_Status = HttpGet(
>     stWeather_Resp,
>     stWeather_Resp_Hdr,
>     stWeather_Send,
>     0,
>     "/",
>     iHttpGet_Cmd_Status,
>     1000,
>     "");

My variable iHttpGet_Cmd_Status is returning 0, but
My variable iWeather_Cmd_Status is returning -40, Not Enough Data Returned

And nothing is loaded into my string.

Any thoughts on what to try from here? I have already tried making my string tables arbitrarily larger (100 entries, 1024 wide) since I started them at minimal sizes. Also, I have experimented with the forslash or backslash in the string command, either works in the command line, and neither has an effect in OptoScript.

That doesn’t look like an HTTP response.

What kind of utility is this?

It is what I supposed was a copy of the httpget command that the opto functions appear to mimic.

This is for an Omega weather station device.

I popped the executable “httpget.exe” into my windows directory, and was able to get the response “0017.4”, which is the humidy % in my office where this thing is laying.

So, this is my first attempt to use the built-in opto function instead of just a command line utility. I’d rather log this weather station data into my SNAP-PAC-R1 then have to run a separate logging utility.

Since I’ve never used any form of HttpGet or HttpPost, I have no idea that the string I’m getting back on the command line isn’t an http response.

Can you get a wireshark trace and see what that utility is sending and what is coming back?

good idea, will do thanks

A day of firsts, also firs time I’ve successfully used WireShark :wink:

Don’t see the data, but those packet lengths are too short to be http.

Hmm -I looked at that utility and the -r option means to just send raw data - so it may return http if that option wasn’t there, it just crashed when I tried it though.

Also you are using /r when the example has \r. \r is most likely an escape for the carriage return character 13.

So on your string you are sending from your strategy you probably should have “*SRH2” + CHR(13) I would check if that magically works for you. If not, then try the TransmitReceiveString command (You will need to open the comm handle yourself first).

1 Like

Thank you, good points and something to try!

Quick update, I’m not done cleaning things up, but the following works, and of course, thank you Philip for the help and guidance!

SetCommunicationHandleValue("tcp:", chWeather);
while (not(IsCommunicationOpen(chWeather)))
  iWeather_Cmd_Status = OpenOutgoingCommunication(chWeather);
iWeather_Cmd_Status = TransmitReceiveString("*SRH2/r", chWeather, sWeather_Resp);

Hmm, so /r works when the docs state \r?

yes, either works in the command prompt using their “httpget”