LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-16-2009, 01:29 PM   #1
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Rep: Reputation: 18
serial port programming and sending ctrl+ Z to it


hello every body
I wrote a program for my serial port for acting like minicom (but very simple) and I wanted to communicate to a gprs modem that I connected it to my serial port. every thing is good and I can send any command and receive its answer and action except control-Z and that is neccesery for me to sending sms via gprs modem, first of all I ignored SIGTSTP in my program for preventing it to stop but it does not work then I wrote function to send 26 (I think code of control+Z)to serial port that it does not work again.
what can I do
please help me.

this is the signal handler and my fuction in my program:
signal(SIGTSTP,ctrlz);

void ctrlz()
{
char ch[2]="26";
SerialOpen( port);
SerialSetSpeed( port, speed);
SerialWrite( port, &ch, 2);
}
 
Old 01-16-2009, 03:06 PM   #2
pa1gupta
LQ Newbie
 
Registered: Jan 2009
Location: New Delhi
Distribution: Ubuntu, Fedora
Posts: 4

Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by golden_boy615 View Post
hello every body
I wrote a program for my serial port for acting like minicom (but very simple) and I wanted to communicate to a gprs modem that I connected it to my serial port. every thing is good and I can send any command and receive its answer and action except control-Z and that is neccesery for me to sending sms via gprs modem, first of all I ignored SIGTSTP in my program for preventing it to stop but it does not work then I wrote function to send 26 (I think code of control+Z)to serial port that it does not work again.
what can I do
please help me.

this is the signal handler and my fuction in my program:
signal(SIGTSTP,ctrlz);

void ctrlz()
{
char ch[2]="26";
SerialOpen( port);
SerialSetSpeed( port, speed);
SerialWrite( port, &ch, 2);
}
To send ctrl+z you need to send only one byte ie 26 not a string "26". So ur sig handler should look like:

void ctrlz()
{
char ch=26;
SerialOpen( port);
SerialSetSpeed( port, speed);
SerialWrite( port, &ch, 1);
}

BTW char ch[2] does not accommodate memory to store the trailing NULL character after "26". Do take care about NULL otherwise result could be fatal.

Best of luck
 
1 members found this post helpful.
Old 01-19-2009, 08:56 AM   #3
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Original Poster
Rep: Reputation: 18
It's now woking

thank u very much for your help it is now working very well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sending control-Z to serial port golden_boy615 Linux - Embedded & Single-board computer 1 01-21-2009 04:42 PM
sending control-Z to serial port golden_boy615 Linux - Newbie 1 01-15-2009 05:49 PM
Sending files over serial port. Fadoksi Linux - General 2 08-01-2007 08:36 AM
Sending and receiving data to through Serial Port kalyan.penujeevi Programming 1 08-07-2006 07:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration