LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-28-2012, 04:02 AM   #16
cgtueno
Member
 
Registered: Jul 2003
Posts: 363

Rep: Reputation: 50

Have a look at:

http://www.linuxquestions.org/questi...-modem-407509/
 
Old 03-28-2012, 04:16 AM   #17
cgtueno
Member
 
Registered: Jul 2003
Posts: 363

Rep: Reputation: 50
Ok
So the board accepts standard input
(your keyboard input), and generate
output on the screen (that's standard
output).

I take it that you are talking to a
linux (BASH) like shell
ie. you can use commands such as
ls, etc

Are you sending the commands to the
modem using a construct similar to
the following ?

echo "ati" > /dev/ttyUSB3

or

echo "ati > /dev/modem

If you are and that works then
you can redirect and append
the output of echo to file
to build a file of modem commands
(eg.
ati9
atdt1234
ath
)
and then redirect that to
/dev/modem

But you need something more sophisticated
(complex) ?

You need to create a shell script that
for each modem activity (command string):
1)sends a command (using echo for example)
to the modem via standard input, and
2)traps the responds from standard output
(in case there is an error processing
the command sent in (1)

Let me know what you think.

Also check in the developer's kit under
software, under the topics of scripts,
and host(PC) to embedded controller
environment/shell file migration.

Continuing to read in the meantime here

C.
 
Old 03-28-2012, 07:10 AM   #18
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cgtueno View Post
Ok
So the board accepts standard input
(your keyboard input), and generate
output on the screen (that's standard
output).

I take it that you are talking to a
linux (BASH) like shell
ie. you can use commands such as
ls, etc

Are you sending the commands to the
modem using a construct similar to
the following ?

echo "ati" > /dev/ttyUSB3

or

echo "ati > /dev/modem

If you are and that works then
you can redirect and append
the output of echo to file
to build a file of modem commands
(eg.
ati9
atdt1234
ath
)
and then redirect that to
/dev/modem

But you need something more sophisticated
(complex) ?

You need to create a shell script that
for each modem activity (command string):
1)sends a command (using echo for example)
to the modem via standard input, and
2)traps the responds from standard output
(in case there is an error processing
the command sent in (1)

Let me know what you think.

Also check in the developer's kit under
software, under the topics of scripts,
and host(PC) to embedded controller
environment/shell file migration.

Continuing to read in the meantime here

C.
No i send AT commands using this costruct:
$ Screen /dev/ttyUSB3 115200
at

OK

at+cgreg?

+CGREG: 0,2

Screen is a program that open a terminal session.

Yes i need to create a shell script that
for each modem activity (command string):
1)sends a command (using echo for example)
to the modem via standard input, and
2)traps the responds from standard output
(in case there is an error processing
the command sent in (1)
 
Old 03-28-2012, 07:20 AM   #19
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Do you have a Linux system that you can connect to the serial port to issue the commands? If so you can run "expect" on that Linux system to interact with the serial port as I originally suggested.

I wonder if the "screen" command you're using isn't a customized thing provided by the board maker rather than the normal "screen" utility we're used to on UNIX/Linux systems. It doesn't seem reasonable that you'd need to run the normal "screen" utility with other commands.

What happens if you open a connection and type "?" or "help"? What happens if you type "screen ?" or "screen help"? What happens if you type "man screen"? There may be other options the board allows for that we don't know. However, my experience with embedded Linux even on systems bigger than a board is that they often limit what you can do to a few pre-defined tasks and I don't recall any I've used that allowed me to do automation beyond what was canned.
 
Old 03-28-2012, 07:29 AM   #20
cgtueno
Member
 
Registered: Jul 2003
Posts: 363

Rep: Reputation: 50
OK

Never encountered 'screen' as a command in Linux used in that manner.
Without that explanation I thought you were referring the display
ie. "Screen" = "monitor", "display", "VDU" for me (and most others I expect.

To do the equivalent of
$ Screen /dev/ttyUSB3 115200

You need two steps
1) Find a command that the shell accepts to configure the serial port to 115200
2) Find a command that allows a shell command line to send data to the port

Has the software guide for the controller got a list of available commands ?
It MUST have surely ?
Does the shell recognize: normal basic BASH shell commands like 'echo' 'cat' and so on ?

I'm still reading the documentation on the manufacturers site.

C.
 
Old 03-28-2012, 07:46 AM   #21
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
Do you have a Linux system that you can connect to the serial port to issue the commands? If so you can run "expect" on that Linux system to interact with the serial port as I originally suggested.

I wonder if the "screen" command you're using isn't a customized thing provided by the board maker rather than the normal "screen" utility we're used to on UNIX/Linux systems. It doesn't seem reasonable that you'd need to run the normal "screen" utility with other commands.

What happens if you open a connection and type "?" or "help"? What happens if you type "screen ?" or "screen help"? What happens if you type "man screen"? There may be other options the board allows for that we don't know. However, my experience with embedded Linux even on systems bigger than a board is that they often limit what you can do to a few pre-defined tasks and I don't recall any I've used that allowed me to do automation beyond what was canned.
giuseppe@giuseppe-K53SV:~/Scrivania$ screen --help
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]

Options:
-a Force all capabilities into each window's termcap.
-A -[r|R] Adapt all windows to the new display width & height.
-c file Read configuration file instead of '.screenrc'.
-d (-r) Detach the elsewhere running screen (and reattach here).
-dmS name Start as daemon: Screen session in detached mode.
-D (-r) Detach and logout remote (and reattach here).
-D -RR Do whatever is needed to get a screen session.
-e xy Change command characters.
-f Flow control on, -fn = off, -fa = auto.
-h lines Set the size of the scrollback history buffer.
-i Interrupt output sooner when flow control is on.
-l Login mode on (update /var/run/utmp), -ln = off.
-list or -ls. Do nothing, just list our SockDir.
-L Turn on output logging.
-m ignore $STY variable, do create a new screen session.
-O Choose optimal output rather than exact vt100 emulation.
-p window Preselect the named window if it exists.
-q Quiet startup. Exits with non-zero return code if unsuccessful.
-r Reattach to a detached screen process.
-R Reattach if possible, otherwise start a new session.
-s shell Shell to execute rather than $SHELL.
-S sockname Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title Set title. (window's name).
-T term Use term as $TERM for windows, rather than "screen".
-U Tell screen to use UTF-8 encoding.
-v Print "Screen version 4.00.03jw4 (FAU) 2-May-06".
-wipe Do nothing, just clean up SockDir.
-x Attach to a not detached screen. (Multi display mode).
-X Execute <cmd> as a screen command in the specified session.
 
Old 03-28-2012, 07:59 AM   #22
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cgtueno View Post
OK

Never encountered 'screen' as a command in Linux used in that manner.
Without that explanation I thought you were referring the display
ie. "Screen" = "monitor", "display", "VDU" for me (and most others I expect.

To do the equivalent of
$ Screen /dev/ttyUSB3 115200

You need two steps
1) Find a command that the shell accepts to configure the serial port to 115200
2) Find a command that allows a shell command line to send data to the port

Has the software guide for the controller got a list of available commands ?
It MUST have surely ?
Does the shell recognize: normal basic BASH shell commands like 'echo' 'cat' and so on ?

I'm still reading the documentation on the manufacturers site.

C.
On board echo and cat commands are supported! is a simple BASH shell configured with BusyBox
 
Old 03-28-2012, 08:01 AM   #23
cgtueno
Member
 
Registered: Jul 2003
Posts: 363

Rep: Reputation: 50
enaud

isn't that the standard Linux 'screen' used for managing multiple terminal sessions from a single shell (connections, reattaching from disconnections), etc.

C.
 
Old 03-28-2012, 08:09 AM   #24
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cgtueno View Post
enaud

isn't that the standard Linux 'screen' used for managing multiple terminal sessions from a single shell (connections, reattaching from disconnections), etc.

C.
and where is my Screen Terminal?

I can use echo, chat, cat etc..
 
Old 03-28-2012, 08:16 AM   #25
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Yes - that is the output for normal Linux screen which as I noted originally doesn't have any built in automation capabilities.

What happens if you type "which expect"? Maybe it is already installed?

Can you do vi to create files on this system? Maybe a simple script would work. Create a file that has all the screen commands you normally do, make it executable then run it.
 
Old 03-28-2012, 08:25 AM   #26
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
Yes - that is the output for normal Linux screen which as I noted originally doesn't have any built in automation capabilities.

What happens if you type "which expect"? Maybe it is already installed?

Can you do vi to create files on this system? Maybe a simple script would work. Create a file that has all the screen commands you normally do, make it executable then run it.
script not work
#!/bin/bash
screen /dev/ttyUSB3 115200
at
at+cpin?

which expect command:

root@freescale ~$ which expect
root@freescale ~$
root@freescale ~$ expect
-sh:expect:not found

 
Old 03-28-2012, 08:53 AM   #27
enaud
LQ Newbie
 
Registered: Mar 2012
Distribution: UBUNTU
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by enaud View Post
script not work
#!/bin/bash
screen /dev/ttyUSB3 115200
at
at+cpin?

which expect command:

root@freescale ~$ which expect
root@freescale ~$
root@freescale ~$ expect
-sh:expect:not found

I think that i have resolved with this script:
#! /bin/sh

cat /dev/ttyUSB3 /home/giuseppe/Scrivania/imsi.txt &
sleep 1
# stty ispeed 115200 ospeed 115200 -echo
# echo AT > /dev/ttyUSB3
chat -V -s '' 'AT+creg?' '' > /dev/ttyUSB3 < /dev/ttyUSB3
sleep 2
chat -V -s '' 'AT' '' > /dev/ttyUSB3 < /dev/ttyUSB3
sleep 2
killall cat
exit 0

what do you think?

and now how i can read answers and put in variables?

thanks
 
  


Reply



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
Write a script which copies content of file 1 to file 2 without using cp command. aashka Linux - Newbie 5 04-10-2012 03:55 PM
[SOLVED] Trying to write a command line script that will make symbolic links dave247 Programming 5 10-21-2010 12:24 PM
Trying to write a bash script -- :Command not found? bpottle Linux - Software 7 06-10-2006 06:11 PM
How to write drivers (e.g., HSF modem drvs?) kornerr Programming 3 03-08-2005 09:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:29 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
Open Source Consulting | Domain Registration