Reply by Tom Collins September 28, 20112011-09-28
I think that DC9 sometimes has problems with complex statements like that one below. A simpler/clearer fix might be to do:

// if Content-Type not provided, use default value

if (! contenttype) contenttype = "application/x-www-form-urlencoded";

i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype, plen);
-Tom
On Sep 28, 2011, at 3:41 AM, ale_biffo wrote:
> Hi everybody,
> the problem is that the Dynamic C 9.62 compiler doesn't evalute an expression correctly in the httpc_post_ext function. I don't know if it is bug or other, but anyway...
> Look at the line 1068 of your httpc.lib. You should see as follow:
>
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype ? contenttype : "application/x-www-form-urlencoded", plen);
>
> The error is generated by the expression "contenttype ? contenttype : "application/x-www-form-urlencoded". I think because the printf is a special function that accepts a variable length array as arguments. If you change this line to (for example):
>
> if (contenttype)
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype, plen);
> else
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", "application/x-www-form-urlencoded", plen);
>
> you should now run your program without any error.
>
> In my case I preferred to leave the library file untouched and rewrite my own version of this function.
>
> I hope this helps you. Bye.
>
> --- In r..., yasja@... wrote:
> >
> > Hi Tom,
> >
> > The only functions that cause this error are the POSTing functions. GETting functions don't give compile-time errors, although they tend to fail during run-time.
> >
> > Peter, I've also tried to place everything in one line (and didn't cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same result.
> >
> > Anyhow, I might be able to proceed with a GET-method, the problem here is that the strings that I'm trying to post are quite long, over 128 bytes. A colleague advised me to split up the XML-strings and send 'em apart.
> >
> > This I'll be trying. Thank you guys for the help.
> >
> > Yasja S.
>
Reply by ale_biffo September 28, 20112011-09-28
Hi everybody,
the problem is that the Dynamic C 9.62 compiler doesn't evalute an
expression correctly in the httpc_post_ext function. I don't know if it
is bug or other, but anyway...
Look at the line 1068 of your httpc.lib. You should see as follow:

i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n",
contenttype ? contenttype : "application/x-www-form-urlencoded", plen);

The error is generated by the expression "contenttype ? contenttype :
"application/x-www-form-urlencoded". I think because the printf is a
special function that accepts a variable length array as arguments. If
you change this line to (for example):

if (contenttype)
i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length:
%d\r\n", contenttype, plen);
else
i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length:
%d\r\n", "application/x-www-form-urlencoded", plen);

you should now run your program without any error.

In my case I preferred to leave the library file untouched and rewrite
my own version of this function.

I hope this helps you. Bye.

--- In r..., yasja@... wrote:
>
> Hi Tom,
>
> The only functions that cause this error are the POSTing functions.
GETting functions don't give compile-time errors, although they tend to
fail during run-time.
>
> Peter, I've also tried to place everything in one line (and didn't
cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same
result.
>
> Anyhow, I might be able to proceed with a GET-method, the problem here
is that the strings that I'm trying to post are quite long, over 128
bytes. A colleague advised me to split up the XML-strings and send 'em
apart.
>
> This I'll be trying. Thank you guys for the help.
>
> Yasja S.
>
Reply by yasj...@ysmgroup.net July 21, 20112011-07-21
Hi Tom,

The only functions that cause this error are the POSTing functions. GETting functions don't give compile-time errors, although they tend to fail during run-time.

Peter, I've also tried to place everything in one line (and didn't cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same result.

Anyhow, I might be able to proceed with a GET-method, the problem here is that the strings that I'm trying to post are quite long, over 128 bytes. A colleague advised me to split up the XML-strings and send 'em apart.

This I'll be trying. Thank you guys for the help.

Yasja S.
Reply by Tom Collins July 20, 20112011-07-20
Yasja,

Sometimes those errors are caused by problems in other libraries, or the order that libraries are included in your program.

Make sure you're #use'ing HTTPC.LIB after any libraries it requires (like DCRTCP.LIB).

Do you get the error if you #use the library but not reference anything from it?

If you reference only some functions, which function causes the problem? You can troubleshoot this by just listing symbols separated by semicolons in main():

int main( void)
{
function1;
function2;
global_var1;
global_var2;

// your program here
}

Including a function name causes the compiler to compile that section of the .LIB file (code between EndHeader and the next BeginHeader). Maybe one of the sections of the library has a syntax error?

Dynamic C's error reporting leaves something to be desired. It definitely improved in recent DC 10 releases (like 10.56 or 10.60 and later), but DC 9.62 still has those problems.

-Tom
On Jul 19, 2011, at 1:22 AM, y...@ysmgroup.net wrote:
> Hi Steve,
>
> You're right, but this doesn't solve my problem.
> Another strange thing is when i click on the error in the compiler messages window, the cursor points to the far right end of the HTTPC.LIB document, way beyond the gray line that delimits the "Beyond this point your code will become ugly" something.
> Anyhow, DC isn't giving me any good clue on what's going wrong, except for the error message
>
> line 4 : ERROR HTTPC.LIB : Operands and/or operator incompatible.
>
> I've been through the whole file now and tried some things in my own source but nothing helps. The included sample source works and even trying it with a basic PPP setup works, but not in the main project. I don't know what information I have to provide to help you guys to help me..?
>
> This project is coming to an end now but obstacles like these are bugging me a lot hehe.
>
Reply by petermcs July 20, 20112011-07-20
Hi Yasja,

It's worth a try. The BACnet stack was full of lines like:

x = fn_y(parm1, parm2,
parm3,
parm);

and

x = yyyyy + zzzzz
* ttttt + hhhh;

and so on which really throws the compilers error tracking off. I suspect the same would be true for the 9.xx compiler.

Regards,
Peter
--- In r..., yasja@... wrote:
>
> Hi there,
>
> The C in HTTPC stands for "Client", it contains functions for retreiving web-stored content through HTTP. It is included with DynC 10.xx, but I got a DynC 9.62 compatible version directly from Rabbit/Digi's tech support.
>
> I will try the single line command thing, this might be the solution to my problem. Thanks Peter.
>
> Best regards,
>
> Yasja S. de Miranda
>

Reply by yasj...@ysmgroup.net July 20, 20112011-07-20
Hi there,

The C in HTTPC stands for "Client", it contains functions for retreiving web-stored content through HTTP. It is included with DynC 10.xx, but I got a DynC 9.62 compatible version directly from Rabbit/Digi's tech support.

I will try the single line command thing, this might be the solution to my problem. Thanks Peter.

Best regards,

Yasja S. de Miranda
Reply by petermcs July 19, 20112011-07-19
In my experience with DC 10.xx the prescence of C statements that span more than one line seems to throw the compilers error reporting off. Many times when porting the BACnet stack, I had to edit the code to make function calls etc fit on a single line before I could get the line number for the error message match up with the actual line in code where the error was.

Regards,
Peter

--- In r..., Steve Trigero wrote:
>
> Dynamic C is notorious for giving erroneous line numbers and compiler error messages.
> Generally, the real error is much earlier in the code than the line DC has flagged.
>  
> What is library HTTPC.lib and how does it differ from HTTP.lib that is
> delivered with Dynamic C?
>  
> Steve
>
> From: "yasja@..."
> >To: r...
> >Sent: Tuesday, July 19, 2011 1:22 AM
> >Subject: [rabbit-semi] Re: RCM3700 HTTP Client on DC9.62
> >
> >
> > 
> >Hi Steve,
> >
> >You're right, but this doesn't solve my problem.
> >Another strange thing is when i click on the error in the compiler messages window, the cursor points to the far right end of the HTTPC.LIB document, way beyond the gray line that delimits the "Beyond this point your code will become ugly" something.
> >Anyhow, DC isn't giving me any good clue on what's going wrong, except for the error message
> >
> >line 4 : ERROR HTTPC.LIB : Operands and/or operator incompatible.
> >
> >I've been through the whole file now and tried some things in my own source but nothing helps. The included sample source works and even trying it with a basic PPP setup works, but not in the main project. I don't know what information I have to provide to help you guys to help me..?
> >
> >This project is coming to an end now but obstacles like these are bugging me a lot hehe.
> >
> >
> >
>

Reply by Steve Trigero July 19, 20112011-07-19
Dynamic C is notorious for giving erroneous line numbers and compiler error messages.
Generally, the real error is much earlier in the code than the line DC has flagged.
 
What is library HTTPC.lib and how does it differ from HTTP.lib that is
delivered with Dynamic C?
 
Steve

From: "y...@ysmgroup.net"
>To: r...
>Sent: Tuesday, July 19, 2011 1:22 AM
>Subject: [rabbit-semi] Re: RCM3700 HTTP Client on DC9.62

>Hi Steve,
>
>You're right, but this doesn't solve my problem.
>Another strange thing is when i click on the error in the compiler messages window, the cursor points to the far right end of the HTTPC.LIB document, way beyond the gray line that delimits the "Beyond this point your code will become ugly" something.
>Anyhow, DC isn't giving me any good clue on what's going wrong, except for the error message
>
>line 4 : ERROR HTTPC.LIB : Operands and/or operator incompatible.
>
>I've been through the whole file now and tried some things in my own source but nothing helps. The included sample source works and even trying it with a basic PPP setup works, but not in the main project. I don't know what information I have to provide to help you guys to help me..?
>
>This project is coming to an end now but obstacles like these are bugging me a lot hehe.
Reply by yasj...@ysmgroup.net July 19, 20112011-07-19
Hi Steve,

You're right, but this doesn't solve my problem.
Another strange thing is when i click on the error in the compiler messages window, the cursor points to the far right end of the HTTPC.LIB document, way beyond the gray line that delimits the "Beyond this point your code will become ugly" something.
Anyhow, DC isn't giving me any good clue on what's going wrong, except for the error message

line 4 : ERROR HTTPC.LIB : Operands and/or operator incompatible.

I've been through the whole file now and tried some things in my own source but nothing helps. The included sample source works and even trying it with a basic PPP setup works, but not in the main project. I don't know what information I have to provide to help you guys to help me..?

This project is coming to an end now but obstacles like these are bugging me a lot hehe.
Reply by Steve Trigero July 18, 20112011-07-18
Regarding this statement:
 
sprintf(&url,"?XML=%s",xml);

I don't think "url" should have an ampersand.
 
I think this is what you want:
 
sprintf( url,"?XML=%s",xml );

Steve

From: "y...@ysmgroup.net"
>To: r...
>Sent: Monday, July 18, 2011 7:20 AM
>Subject: [rabbit-semi] Re: RCM3700 HTTP Client on DC9.62

>Hi there,
>
>I'm running into another problem with this. When i try to compile my program, the compiler gives an error from HTTPC.LIB
>
>line 4 : ERROR HTTPC.LIB : Operands and/or operator incompatible.
>
>Line 4 contains
>
>/*** EndHeader */
>
>Although i'm used to misleading error line numbers now i can't find this one anywhere. I got the lib directly from Digi, as the library wasn't included with DC9.62.
>
>It runs fine with the included sample program. I call httpc_post(/*...*/) like this:
>
>int postReset(char xml[128])
>{
>int retval;
>char url[128];
>sprintf(&url,"?XML=%s",xml);
>gprsAttach();
>if(ifstatus(IF_PPP3))
>{
>printf("\nEstablished PPP link. Now POSTing XML.");
>retval = httpc_post ( &mysock, host_addr,
>host_port, "/M/X/pt01.xml", NULL,
>url );
>ModemEscape();
>printf("\nhttpc_post( ... ); returned %d",retval);
>return retval;
>}
>else
>{
>printf("\nPPP link failed. Pun was not intended.");
>return 1;
>}
>}
>