I'm working on using a UART for an OBDII setup. I've got some sample code and for the most part I understand what is going on. However, I'm not to clear on a statement. Here it is:
vehicleSpeed = strtol(&rxData[6],0,16)
I understand that strtol is string to integer and the &rxData[6] is pointing to the address of the variable rxData, and I believe specfically the address for the sixth place holder in the array rxData, but I'm not sure about the rest of the statement. The ,0,16 part. Any help would be greatly appreciated. I'm not the strongest programmer....
The second parameter is the end pointer. It will be set to the position in the string where the strtol has stopped.
"If endptr is not NULL, strtol() stores the address of the first invalid character in *endptr.".
Instead of "NULL", a value of "0" is used. It is the same, but it is not nice to do so.
The third parameter is the base. A value of 16 is for an hexadecimal conversion.
This is the same : vehicleSpeed = strtol ( rxData + 6, NULL, 16);