Yes it works!!!
now, how do i go about copying int type array items into unsigned char type array?
is the following legit syntax?
arrayofuchars[deviceid][index] = arrayofints[deviceid][index];
or
arrayofuchars[deviceid][index] = (unsigned char) arrayofints[deviceid][index];...
User Profile
Collapse
-
I get some strange result, most of characters are 0's except the last 2 digits which gets converted correctly.....n ot sure why
when row[0] is 36000800402AE11 0
arrayofuchars[NumDevices] has 000000000000001 0
and it does this for all items, not sure why only the 10 gets converted correctly.
my exact syntax is as follows:
Code:sscanf(row[0],"%02X%02X%02X%02X%02X%02X%02X%02X",&arrayofuchars[NumDevices][7],&arrayofuchars[NumDevices][6],&arrayofuchars[NumDevices][5],&arrayofuchars[NumDevices][4],&arrayofuchars[NumDevices][3],&arrayofuchars[NumDevices][2],&arrayofuchars[NumDevices][1],&arrayofuchars[NumDevices][0]);
Leave a comment:
-
I have tried the following without much luck:
Code:mysql includes; declare and init other varibles etc; int NumDevices =0; other mysql related initialization, not shown to keep things simple; sprintf(query, "SELECT distinct ucase(deviceid) from tlogs where devicetype='10'"); mysql_real_query(&mysql,query,(unsigned int)strlen(query)); res = mysql_use_result(&mysql);
Leave a comment:
-
Continuing the fun,
I now want to do the reverse of course, read from mysql database, and copy the deviceid into a variable, resulting in the same format.
when I receive the mysql result, the result is in string format, how do i go about converting those exact address such as 3500080047222E1 0 and correctly placing them in an array?...Leave a comment:
-
horace1, thats exactly what I was looking for.....thanks a million
following is what I came up with, and it works!!!!
sprintf(devicea ddress,"%02x%02 x%02x%02x%02x%0 2x%02x%02x",Fam ilySN[i][7],FamilySN[i][6],FamilySN[i][5],FamilySN[i][4],FamilySN[i][3],FamilySN[i][2],FamilySN[i][1],FamilySN[i][0]);
sprintf(query, "INSERT into tlogs (id, deviceid, devicetype, temp, logtime, logdate)...Leave a comment:
-
Sure.
My following code is a direct copy from Dallas/Maxim's site, I have tried to incorporate the Mysql c api in it as well so I could directly send the measured temperature information to a sql table.
for the fullsource code from dallas, please visit the following site to get their sdk
:
http://files.dalsemi.com/auto_id/pub...inuxgnu300.zip
Following is my hacked c code, please bear...Leave a comment:
-
-
how to convert array of uchar to string
hello
I am new to C and not sure how to go about getting the following accomplished:
I have the following c code, under centos ver 3.4, using gnu gcc to compile:
uchar sn[8];
// readings
sn[0] = 0x10;
sn[1] = 0x2E;
sn[2] = 0x22;
sn[3] = 0x47;
sn[4] = 0x00;
sn[5] = 0x08;
sn[6] = 0x00;
sn[7] = 0x35;
I want to convert...
No activity results to display
Show More
Leave a comment: