Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

passing data to device driver in linux

Status
Not open for further replies.

garimella

Full Member level 5
Joined
Aug 25, 2011
Messages
260
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,276
I want to write a simple application that can pass 2 integer's data to linux device driver. What is the method?
 

You need to know exactly where the driver software looks, so it can access data which it uses. Is it somewhere in ram, in a device, in a disk file, in a sensor? Etc.

Or, does the driver already have a built-in routine which looks for a flag, to notify it that it should access your data?

You also need to make sure:
* that your data is available at the time it is needed.
* that nothing overwrites your data beforehand.
* that your data doesn't cause anything to go wrong somewhere.
 

This device driver is only pseudo, for learning purpose only. I am just learning to pass an integer to char driver which will manipulate the data and give the result. I find that strings work very well with write () system call, whereas we have problem with integers. Could you explain how to pass integers using write system call to the driver
 

Number formats need to match at both sender and receiver.
* Number of bytes
* Signed vs. unsigned
* Suppression of leading zero's
* Little or big endian
* Position of decimal point
Etc.
The least little non-matching thing can generate an error. And there may be a sequence of coded values which the driver expects to get, in addition to your data.

Anyway, since you have succeeded with strings, look for ways to convert a number back and forth from a string.

Can you convert 153 to a string by calling a function such as:
a$=STR$(x)
Send as a word consisting of three characters (namely "153").
Then at the receiving end call a function such as:
x=VAL(a$)
in order to recover the number.

Or another way, send characters whose ascii values can be assembled, or added, or subtracted to recreate your data.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top