working with one exception that I am having trouble with.
One feature of the webpage is to get calibration data from the module and display it in a graph. This works.
But the webpage is also supposed to be able to send calibration data to the module. This is the part that
doesn't work.
To get the cal data, the webpage sends a GET command, which invokes a callback function declared with CallBackFunctionPageHandler.
The callback function calls SendTextHeader(sock) followed by a series of writestring calls. The cal data is stored as binary
integers on the module, but converted to ASCII hex values to send to the webpage. The cal data after converting to ASCII hex
is 6448 bytes plus a terminator \0.
To send the cal data to the module, this javascript is used:
Code: Select all
function UploadTable()
{
var i=upload_step;
var s;
http = new XMLHttpRequest();
http.open("POST","0.htm",true);
start = i*2*0x1000;
s = "CAL_TABLE"+i+"=";
s += calfile.raw[i];
http.send(s);
}
In the module is this code:
Code: Select all
HtmlPostVariableListCallback mainformpost("0.htm", WebIncomingPost );
#define MAX_POST_DATA 6500 // Biggest block is cal table... (800+6) integers = 3224 bytes, x2 for hex string = 6448 + \0 terminator.
char cmd_post_string[MAX_POST_DATA];
void WebIncomingPost( int sock, PostEvents event, const char *pName, const char *data )
{
int i;
switch ( event )
{
case eStartingPost: break;
case eVariable:
i = (int) strlen( data );
if ( i == 0 ) return; // No data?
iprintf( "WebPost pName: %s, data len = %d\r\n", pName,i );
if ( StrMatch( pName, "cmd_string" ) )
{
siprintf( cmd_post_string, "%s\r\n", data );
StoreCmdPacket( NULL, cmd_post_string, false, i+2 ); // add string to command fifo.
}
else if ( StrMatch( pName, "CAL_TABLE" ) )
{
CalTablePost( sock, data ); // save cal data.
}
break;
case eFile: break;
case eEndOfPost: break;
}
}
The 255 bytes of data are the first 255 bytes the cal data. But that's all that ever shows up.
However, wireshark captures over 6k of data being sent.