#: 20569 S3/Languages
19-Nov-94 21:22:54
Sb: #20568-#_gs_rdy() question
Fm: Bob van der Poel 76510,2203
To: David Breeding 72330,2051 (X)
David, A few things for talking to the modem....
1. You have to turn off echo! Otherwise what the modem sends back is sent back
to the modem.
2. You should use read() to get stuff, but writeln() to send.
3. _gs_rdy() never returns 0. It returns 1..? if there is data, -1 if there
isn't.
So, here is a program which works:
#include
#include
#include
int mdm;
char buf[30];
char cmd[10] = "AT\n"; /* try something else, too */
struct sgbuf mpathbuff;
main()
{
int count, state;
if ( (mdm=open("/t3",S_IREAD+S_IWRITE)) == -1)
exit(1);
_gs_opt(mdm, &mpathbuff); /* make sure that echo if off to the */
mpathbuff.sg_echo=0; /* modem, otherwise we shoot ourselves */
_ss_opt(mdm, &mpathbuff); /* when reading... */
writeln( mdm,cmd,5);
while (1)
{
state=_gs_rdy(mdm);
if(state<0)
{
printf("No data at modem, state=%d\n", state);
exit(1);
}
count=read(mdm, buf, state);
printf("state=%d count=%d buf=%s\n", state, count, buf);
}
}
Hope this helps.
There is 1 Reply.
|