LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-01-2006, 12:15 PM   #1
ericcarlson
Member
 
Registered: Jan 2002
Posts: 162

Rep: Reputation: 30
Should be dead simple - read/write serial port from bash


Hi, I can only use bash for this and although there are many C examples just need the basics of reading & writing to a serial port, its controlling a modem.

I'm trying things like this

#!/bin/sh
echo ATD555667676; > /dev/ttyS1
read LINE < /dev/ttyS1
echo $LINE

but its not sending it (minicom is fine, its not a hardware problem).
Basically I just need the read and write commands, I want to do things like "Send AT", wait for "OK", "Dial number" when recieved, if "BUSY" then blah blah...
Thanks in advance
 
Old 09-01-2006, 12:21 PM   #2
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Rep: Reputation: 30
Quote:
Originally Posted by ericcarlson
Hi, I can only use bash for this and although there are many C examples just need the basics of reading & writing to a serial port, its controlling a modem.

I'm trying things like this

#!/bin/sh
echo ATD555667676; > /dev/ttyS1
read LINE < /dev/ttyS1
echo $LINE

but its not sending it (minicom is fine, its not a hardware problem).
Basically I just need the read and write commands, I want to do things like "Send AT", wait for "OK", "Dial number" when recieved, if "BUSY" then blah blah...
Thanks in advance
take away that ; that you have in between the ATD string and the > /dev/ttyS1.

echo ATD555667676 > /dev/ttyS1
 
Old 10-21-2006, 02:04 PM   #3
seraph-seph
Member
 
Registered: Jul 2005
Location: /dev/ATX3
Distribution: Slackware 11(kernel 2.6.17.13), SuSE 10, Caldera, CentOS 4.3
Posts: 38

Rep: Reputation: 15
Hi

I'm having some troubles reading the serial por using cat /dev/ttyS0 since the data received does not have the return carriage (char 13), insted of it uses the char 20 to idicate the end of transmission.

Any sugestions how to print or read the buffer without using cat

Mario
 
Old 10-21-2006, 08:35 PM   #4
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
How are you setting the baud rate and flow control parameters. Modems are especially picky.
 
  


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
is there any shell command to read and write data from parallel and serial port? baosheng Linux - Hardware 2 01-13-2007 08:35 PM
Bash Sleep vs crontab and bash serial port nutthick Programming 4 06-01-2006 02:42 AM
Dead Serial Port jmal Linux - Hardware 2 01-31-2006 01:35 PM
Serial port Read Write SeanatIL Programming 2 07-14-2004 03:42 PM
Why can't I read in data from the serial port using a bash script? tjt Linux - Newbie 1 06-17-2004 12:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:15 PM.

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
Open Source Consulting | Domain Registration