Help with 56kbit Modem Scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with 56kbit Modem Scripting
# 1  
Old 06-20-2017
Help with 56kbit Modem Scripting

Hi all,


I have been working on an unique script of my own, which should be able to communicate with a classic 56kbit modem. I am quite a newbie to the scripting, but I suppose I am slowly making a progress.

At the beginning I had no idea how I was supposed to communicate with the modem. I am a Mac user (but I am using Debian as well) and I use the Terminal app mostly for everything and it works pretty fine, I'd say. For a physical connection with the modem I am using a USB-to-RS232 (serial port) adapter (AXAGO ADS-50) at /dev/cu.usbserial*.

For turning on the TR (terminal ready) signal I have already used a cat command followed by a ampersand to make it go to the background. At this point I mark a PID number to myself to kill it afterwards. (I am having some problems with a jobs implementation at the moment.)

To the modem I send AT commands using the echo command, eg. echo -n ATH^M > /dev/cu.usbserial*. (The ^M sing at the end is a combination of CTRL-V and CTRL-M characters.)

The script(s) itself works quite fine. It initialises the modem, makes it go offhook, even is able to make a genuine connection between two 56kbit modems. I can send text strings through the modems to each other and I am working on a simple script which can send (cat > device) simple text files.

And here comes the problem. Just today I have found out how to hang-up the modem, but since I process ATH0 to one modem and the other one hangs as well, the second modem also drops the cat > device process, the TR signal of this modem is still on and I cannot use it anymore untill reboot. I tried to kill that process with kill PID, but it cannot be found even in the ps ax list. If I kill the process before the dialling and making of connection, the TR signal successfully disappears.

I am stuck at this point and I have no idea, how could I make it work properly. I have realised that the second modem sends a EOF signal (^D) to the log before the cat process drops.

I would be glad for any help. Thank you and sorry for a long post and a poor level of my English.


- krustowski (krusty was not available already)
# 2  
Old 06-21-2017
You can do better than cat, and should use printf, which supports escape sequences natively:

Code:
#!/bin/bash
trap "echo 'whoa doggies'" SIGHUP

exec 5<> /dev/cu.usbserial* # BASH required for bidirectional open

printf "ATH\r\n" >&5

SIGHUP is what kills processes when a terminal closes, which a shell can catch and respond to as it pleases.

Also check out man stty for a parade of options related to terminal devices, serial ports, and modems, including such things as cr-lf translation and flow control.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 06-22-2017
Have you thought about using exec to redirect all of the output to the modem?
Another option would be to write C or Java code to do the scripting.

Code:
export CURR_TIME=`/bin/date +%Y%m%d_%H%M%S`
exec  >/dev/cu.usbserial*
exec 2>/home/user/log/modem_connection_${CURR_TIME}.log
printf "...

I can't help but wonder why in this increasingly connected world someone would
want to do anything with a modem. What can you do using a modem that you can't
do using the internet?
This User Gave Thanks to gandolf989 For This Post:
# 4  
Old 06-22-2017
Quote:
Originally Posted by gandolf989
I can't help but wonder why in this increasingly connected world someone would want to do anything with a modem. What can you do using a modem that you can't do using the internet?
There's still a few corner cases here and there, like old POS applications. I had to dig out an external 56K modem to deal with an old food service's reporting program. They'd just upgraded their hardware, and their crummy afterthought of a winmodem didn't work two boots out of three. That place was fascinating - four generations of computers gathering dust on the shelves. Eight-inch floppy disks. The works.

Other applications: Some cell phones pretend to be a modem, with extended AT commands to send text messages.

And in the developing world, modems are alive and well. There's been renewed interest in dialup connections, deferred-transfer things like UUCP, etc.
# 5  
Old 06-25-2017
Thank you both for reply! Unfortunately, I am not quite sure how to use the exec command. It seems like that the tother method (<>) is quite useful, but I have no idea how can I write to the log continuously.

Quote:
I can't help but wonder why in this increasingly connected world someone would
want to do anything with a modem. What can you do using a modem that you can't
do using the internet?
The reason is simple – I am interested in these old devices, because it is not that hard to make them work and it is quite fun to explore the old times' networking.
# 6  
Old 06-28-2017
Quote:
Originally Posted by krustowski
Thank you both for reply! Unfortunately, I am not quite sure how to use the exec command. It seems like that the tother method (<>) is quite useful, but I have no idea how can I write to the log continuously.
You use it like I show it, basically. It's among other things the shell's "open a file" setting. Here I use it to open file descriptor 5, in read-write <> mode.

File descriptors 0, 1, and 2 are standard in, standard out, and standard error, respectively. Numbers 3 and up are generally not opened yet in a shell and can be used as you please.

Code:
exec 6<inputfile # Open file for read
read LINE <&6 # Read a line from it
exec 6<&- # Close file

exec 7>logfile # open a file for write
echo asdf > &7 # Write to file
exec 7>&- # Close file

Does my code not work, or not fulfill your purpose? What is your question?
# 7  
Old 06-29-2017
In my script I use the cat and echo commands like this:

Code:
cat $DEVICE > $LOG &
echo -e "sth" > $DEVICE

And I want to use exec instead, but I have no idea how can I capture the device to the log and printf to the same descriptor. I need the capturing of the modem to check (by grep) if there is any OK response or for example the CONNECT response.

Last edited by krustowski; 06-29-2017 at 08:51 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Modem

hi folks, i am looking for a analog modem to use it with a solaris9 sparc mashine. as far as i know, solaris communicates with the modem using AT-commands. so do i need a special modem for solaris or just a modem? i am open for everything. PCI-modem, seriell modem, usb modem. what are you using? i... (1 Reply)
Discussion started by: pressy
1 Replies

2. SCO

Installing a MODEM on v5.0.2

Hi, my first Sco question so go easy! We have a customer who is on Sco v5.0.2. We are attempting to talk a consultant on site through how to configure the MODEM in scoadmin. Unfortunately the MODEM install instructions that we work from only work for v5.0.4 and assume that scoadmin has an option... (1 Reply)
Discussion started by: Ric.Hemsley
1 Replies

3. Solaris

Is the cable you are using a null modem cable or a modem cable

Hi all, Is there any difference between a null modem cable or a modem cable ? i assume that a null modem cable is a normal cable that i used from cpu serial ports to a modem for dialup. please correct if i am wrong, thks (2 Replies)
Discussion started by: waterbear
2 Replies

4. UNIX for Dummies Questions & Answers

Modem - Test /dev/modem

Ok. I tried following the directions from some of the other threads, but I've hit a road block. I have red hat 7.3 and I installed the hcf package: hcfpcimodem-0.99lnxtbeta03042700k2.4.18_3-1rh.i386.rpm It installed ok, no errors, but I still can't get linux to find my modem. I've tried... (2 Replies)
Discussion started by: lawadm1
2 Replies

5. UNIX for Dummies Questions & Answers

modem

I have got Suse 8.0 by using a modem (US Robotics 56K Faxmodem Ext). During connection i got the error 16. I tried it under RedHat and Mandrake too.....same problem. What can i do ? Thanx...a lot... Logfile: SuSE Meta pppd (smpppd), Version 0.73 on zuhause. wwwoffle not is running ... (1 Reply)
Discussion started by: Pennywize
1 Replies

6. UNIX for Dummies Questions & Answers

Modem

Pleaseee... Helpppp.... !!! I am using SCO Open Server 5.05. Recently, i have upgraded the system which means transfer all apps and data to the new system. Everything work well except one thing. On my old system i have an external modem which to dial out. Now that i use the same modem on... (4 Replies)
Discussion started by: jackpotp
4 Replies

7. UNIX for Dummies Questions & Answers

Modem Volume

Specs: Dlink DFE-560EL external modem. RedHat 7.1 How do you turn off the modem volume? I am getting annoyed of it beeping everytime I use it but there is no switch on the hardware to tune down the volume. I have tried using minicom and use the following commands: ATL0 ATM0 Next, I... (2 Replies)
Discussion started by: arz
2 Replies

8. UNIX for Dummies Questions & Answers

Modem problem: "Sorry, modem is busy"

Hi! I have a little prob with dialing up to the internet... When I try connect, it says "Sorry, modem is busy"... Specs: Laptop 56K modem Slackware 8.0 Kernel 2.4.5 Cheers;) (4 Replies)
Discussion started by: satan404
4 Replies

9. UNIX for Advanced & Expert Users

Modem

I've spent enough time trying to put on work Lucent Winmodem in my armada M300 (compaq laptop) I use Mandrake 8.0 but as soon as i get connected and prompmts appears modem shutsdown. Does any one had a similar situation, solved it? cheers (2 Replies)
Discussion started by: alex blanco
2 Replies

10. UNIX for Dummies Questions & Answers

Modem on HP-UX 10.20

Hi everyone I am having some real difficulties getting a dial in modem to work on one of my HP boxes. It's a mux modem on port 7 which I have set up at 9600 baud. I can dial in, the handshakes are completed, but then it returns incoherent characters on the emulation screen. I think my dial in... (1 Reply)
Discussion started by: alwayslearningunix
1 Replies
Login or Register to Ask a Question