# [SOLVED] Chat scripts and modems

## pa4wdh

Hi All,

I'm trying to make chat talk to a modem (in this case a HSO based HSUPA module). I'm used to doing this via pppd, but in this case i don't need pppd so chat has to do it by itself  :Smile: 

I'm trying this command:

```

chat -s -V -f chatscript < /dev/ttyHS1 > /dev/ttyHS1

```

However, it doesn't do anything and waits forever.

Can anybody give me a hint on how to do this ?

Thanks.

Best regards,

pa4wdh

----------

## NeddySeagoon

pa4wdh,

At the risk of paraphraing Commander Powell from Dark Star, you go and talk to it first.

Fire up minicom and give AT commands.  When you say AT, the modem should respond ok.

Normally, chat is used to authenticate and start PPP.

When you know what works, you can put it in your chat script.

----------

## pa4wdh

Thanks for your answer NeddySeagoon, but that isn't really the answer i was searching for  :Sad: 

Maybe i should explain a bit more to clarify the question:

The device i'm using is a bit unusual, usually you give some AT commands and then the ppp session starts over that serial link. In this case it doesn't. I need to send some commands, but there will be no ppp. That's why i'm using chat itself instead of pppd+chat. I indeed verified using minicom that the modem is alive and responds to AT commands. But now the question: How can i make chat to talk to the modem device ? The script itself works ok on stdio (given that I type OK every now and then to "emulate" the modem).

----------

## dermund

If you don't care for the answer of the modem, you can just tell it something like that.

```
echo -ne "AT+CFUN=1,1\r" > /dev/ttyHS1
```

You should however not spam the modem in this way. If you tell it many commands give it a moment to settle after each command.

At least that always worked for me.

If you need the answer of the modem, did you first try with a really simple chatscript:

```
"" "AT"

OK
```

Can you post your chatscript?

Also, does the chat produces any output if you invoke it with '-v' (verbose) ?

----------

## NeddySeagoon

pa4wdh,

Explain how you will use the modem - whats it talking to.

Chat makes a log - whats in the log?

Warning: Passwords are logged in clear text, so you might want to address that before you post the log

----------

## pa4wdh

@dermund:

Thanks for the tip, but i do need to parse the output of the modem.

@NeddySeagoon:

The HSO devices are a bit different than normal modems, they need some special commands and will make a GPRS session. However, this is not done with a PPP link to the computer but it has a "hso0" interface which shows up with ifconfig.

The actual chat script is currently on a different PC which doesn't have internet connection, but it looks the same like this one:

```

ABORT   'BUSY'

ABORT   'NO CARRIER'

ABORT   'ERROR'

''      AT

OK      AT+CGDCONT=1,"IP","\T"

OK      ATDT*99***1#

```

Of ocurse the AT command's are different in the actual chat script i'm using, but if i start chat with the command listed in my first post in this topic it just waits forever ( i guess it's waiting for an OK from the modem).

I'm not aware of any log file for chat other than what's send to stdout and stderr, and both give no output at all. Is there any other log ?

I don't really think we should try to troubleshoot the chat script itself, but i'm searching for the way to make chat send it's output to a modem and receive it's input from the modem to get interaction. This functionality is usually provided by pppd, but how should i do that without pppd ? Or, of course, is there a better tool for this job ?

----------

## dermund

 *pa4wdh wrote:*   

> I'm not aware of any log file for chat other than what's send to stdout and stderr, and both give no output at all. Is there any other log ? 

 

When chat is invoked like "chat -s -V -v -f ...< /dev/device > /dev/device" all the communication is printed on the console - if there actually is something.

With the above syntax I can  talk to my modem flawlessly, but I have a quite common HSDPA modem - I guess your device uses the hso.ko driver, so maybe these links I stumbled upon may apply to you (altough I wonder how you can talk the modem with a mini-/microcom, if the below is true, nah ) :

 *http://www.xs4all.nl/~ernstagn/GPRS-HOWTO/GPRS-HOWTO-3.html#ss3.12 wrote:*   

> ...
> 
> Because of this new method, the regular AT commands found in this HOWTO do not work. Along with the hso driver you also received a shell script called connect.sh. Edit it to contain your information in the APN, USR, PAS and PIN variables. After then use ./connect.sh to initialize your card, ./connect.sh up make a connection and ./connect.sh down to disconnect again.
> 
> ...

 

 *http://www.gentoo-wiki.info/Telstra_and_Bigpond_Modems wrote:*   

> ...
> 
> This modem comes from Telstra/Bigpond as a 3 series modem capable of 3.2Mbps. There are other documents on the web that describe how to connect with the original firmware models (see the Quozl BP3 guide) . As I understand it, the firmware update to enable the 7 series speeds of 7.2Mbps disables the standard AT modem interface so using the usual ppp and chat scripts is not possible anymore. The solution is to use the custom "Connect.sh" scripts along with the hso.ko kernel module available in the driver download from Pharscape. Please make sure you run "lsusb" (part of sys-apps/usbutils) and check the device ID is the same as mine (0af0:6711). If it's not you may be able to make it work with usbserial/airprime/sierra as per Quozl's guide instead.
> 
> ...

 

If that rings a bell somehow, you may look if you find something useful from this pharscape site or look here - it's from the openwrt project, but it's quite a collection of scripts, which maybe are helpful for you.

That's all I have, hope it helps.

----------

## pa4wdh

Thanks for the hints on chat. I tried it with a modem I know that works an see all the logging, this should be useful. Tomorrow i'm able to try to the HSO modem again and see what i can get. I also just thought: Maybe it's just the "serial port" settings ? Like waiting for hardware flow control while there isn't one ? I'll have to find out how to change that, i thought stty was the tool for that, right ?

Also thanks for quoting my own HOWTO  :Smile:  I found the connect.sh script and they seem to use the same way to use chat as i am (with in- and output redirection), there no other neat trick there  :Sad: 

----------

## dermund

 *pa4wdh wrote:*   

> Also thanks for quoting my own HOWTO  

 

lol

This is going off my competence.

I hope Neddy can help you more  :Wink: 

----------

## NeddySeagoon

pa4wdh,

Chat does not use PPP to talk to a modem, it does it all itself.  Taking your script

```
ABORT   'BUSY'

ABORT   'NO CARRIER'

ABORT   'ERROR'

''     AT

OK      AT+CGDCONT=1,"IP","\T"

OK      ATDT*99***1# 
```

Chat sets up some conditions on which it will abort, the next line means listen for nothing from the modem, then send AT.

The next line is listen for OK from the modem then send AT+CGDCONT=1,"IP","\T"

Then it listens for OK before sending ATDT*99***1# 

I would have expected the line 

```
''      AT
```

 to be 

```
''      ATZ
```

as ATZ is a command to reset the modem.

----------

## pa4wdh

Aarrgghh, sometimes for the simplest problems it's way to hard to find out what causes it  :Sad: 

There's nothing wrong with chat, with the script ...

The real problem was that i was using, or at least intended to use, the -V option ... but i forgot the -. Now chat doesn't see that as an illegal option but interprets it as a script, so it patiently waited until it found a V, which it doesn't find because the modem won't say anything  :Smile: 

Now i corrected it and it works ok  :Smile: 

As for the AT versus ATZ: Since this is not a regular modem the ATZ doesn't really add anything useful, the line is there just to get the conversation going.

Thanks for your help NeddySeagoon and Dermund

----------

