Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8427093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:42:17+00:00 2026-06-10T04:42:17+00:00

Hi i want to pass a data from my char device driver to serial

  • 0

Hi i want to pass a data from my char device driver to serial port ttyS0..

I have created a simple char driver module which reads and write and it’s my first tym doing it.. i am using debian guest os…

e.g.

echo “hello” > /dev/mydev

now when /dev/mydev receives the data it will then alter the string into something like “hello too” which is passed to my serial port /dev/ttyS0..

how can i alter the string?.. is it possible to use if statement inside mydev?

e.g

if(string=="hello"){
alterstringTO: hello to;

pass "hello to" /dev/ttyS0;

like echoing in terminal..

echo "hello to" > /dev/ttyS0
}

Is that possible?… or is there any other way doing it?

Here some of the code..

ssize_t dev_read(struct file *filp, char *buf, size_t clen, loff_t *f_pos){

short cnt =0;
while(clen && (msg[Pos]!=0))
{
    put_user(msg[Pos],buf++);
    cnt++;
    clen--;
    Pos++;
}
return cnt;

    }


   ssize_t dev_write(struct file *filp, const char *buf, size_t clen, loff_t *f_pos){

short dec = clen-1;
short cnt=0;
memset(msg,0,50);
Pos=0;
while(clen>0)
{
    msg[cnt++] = buf[dec--];
    clen--;
}
return cnt;
    }

Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:42:18+00:00Added an answer on June 10, 2026 at 4:42 am

    Just a comment on writing to the serial port:

    Remember the Linux foundations, everything is a file in Linux. To write to the device driver from a program you need to open the file for writing and then you can fprintf whatever data you want. You can do that from user space as well (the recommended way)

    Refer to the following man pages:

    • man fopen
    • man fread/fwrite
    • man fprintf
    • man fclose
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two flex applications and i want to pass the data from one
i have a std::vector, namely vector<vector<vector> > > mdata; i want pass data from
I want to pass data from second tab to first tab using delegates.But delegate
I want to pass data from database to JSF page as a table. I
My data is just number, I want pass it from VC1 to VC2 for
I have two pages and I want to pass data to each other. How
I have an NSMutableArray of names. I want the pass the data (selected name)
When we want to pass data from an activity to a sub activity we
I want to pass data from client side to server-side. I am using jQuery
I want to pass data from form1 to form2 and i used The Properties

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.