We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi everyone, I have an array eg:
command[9] = {0x3C , 0x4A , 0x33 , 0x25 , 0xB1 , 0xD3 , 0x59 , 0x34 , 0x2E }
//init outside unsigned char k[4]; long value;
k[0] = command [5]; k[1] = command [6]; k[2] = command [7]; k[3] = command [8]; value= strtol (k, NULL, 4); value= value+3; sprintf ( k, "%Ld\n" , value); buf[4] = k[0]; buf[5] = k[1]; buf[6] = k[2]; buf[7] = k[3]; sendcom ( buf , 15);//send to serial function
"If your data is actually structured, then why not structure it? ... If you do want to keep the command in a byte array..." You could use a union - then you could have your cake as a struct and eat it in bytes, too!