Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to convert hex string to integer using some lib utility, instead of writing it myself.
sscanf, strtol failed to pass compilation.
Then I tried atoi, which returns 0.
Here is the relevant input, code, and log:
Input (dispatch is a process that calls device drive):
/usr/htdr/bin/dispatch 0x35 0x0b 0x130 1 U1400.1B1.019DF02-P1-C3
Code:
int mapRemoteCommand (char *arg, char *rasSimulatedArg, int *op) {
int subCommand;
char *op_str;
char *subCommand_str;
I can not figure out what you want to do, e.g what you mean with "hex string" - is it a data stream, a simple string of bytes with values from 32 to 255 terminated by 0, ... ?
And explain what you want to convert:
-data coming from X having this
-data structur
-have to be converted to structure Y because ...
-to can be used for what (to do)
I am trying to convert hex string to integer using some lib utility, instead of writing it myself.
sscanf, strtol failed to pass compilation.
Then I tried atoi, which returns 0.
Why did these fail to compile? The compiler doesn't know that it is compiling a device driver, so it should be just standard C.
Hello ira,
Sorry, but I was not permitted to send the routine.
You will have to think how to build the number by translating each digit from ascii to integer, then consider the position in the number.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.