ts-7000
[Top] [All Lists]

Re: [ts-7000] SocketModem problem

To:
Subject: Re: [ts-7000] SocketModem problem
From: Matthieu Crapet <>
Date: Tue, 06 Dec 2005 22:01:31 +0100
Greetings,

Looked quickly to your tty code; you should double check your termios 
settings according to libc documentation.

http://www.gnu.org/software/libc/manual/html_node/Terminal-Modes.html#Terminal-Modes

You should not bzero your "options" variable. And maybe set useful 
values to "options.cc_c[VMIN]" et "options.cc_c[VTIME]" for you later read.

Good luck !!!!

Matthieu

PS: If you don't want to waste your time with all theses flags, you can 
use python, it's very simple :)


alipiec wrote:

>I have TS-MODEM2 additional board with MultiTech socket modem on it.
>The device is recognized at boot procedure. It's visible on
>/dev/tty/3. So until this moment everything looks fine. The board is
>responding - because I have RTC on it and date is backed up during
>power off time.
>
>I tried to send any command: "ATZ\r" and "AT\r" and "AT+WOPEN=1\r" and
>modem doesn't seems to respond. Serial settings for /dev/tty/3 are:
>baudrate 115200, 8N1. What's wrong? Modem should respond "OK". I got
>nothing.
>What could be wrong with following code?
>
>Alus
>===========
>
>/*
>RS simple test
>Arkadiusz Lipiec - arkadiusz.lipiec AT NO_SPAM gazeta.pl
>*/
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#include <unistd.h>
>#include <fcntl.h>
>
>#include <termios.h>
>#include <sys/ioctl.h>
>#include <sys/time.h>
>
>int fd;    //! RS file descriptor
>
>int rs_open()
>{
>   struct termios options;
>
>    fd = open("/dev/tts/3", O_RDWR | O_NOCTTY | O_NONBLOCK);
>
>   if(fd == -1)
>   {   
>       perror("cannot open port\n");
>       return fd;
>   }
>
>   fcntl(fd, F_SETFL, FASYNC);
>
>   tcgetattr(fd, &options);
>   bzero(&options, sizeof(options));
>   options.c_cflag |= (CS8 | B115200 | CREAD | CLOCAL);
>
>   // Enable data to be processed as raw input 
>   options.c_lflag &= ~(ICANON | ECHO | ISIG);
>   options.c_iflag = IGNPAR;
>   options.c_oflag = 0;
>   tcflush(fd, TCIFLUSH);
>   
>   // Set the new options for the port
>   tcsetattr(fd, TCSANOW, &options);
>   return 0;
>}
>
>
>// timeout in ms...
>int receive_data(int fd, unsigned char* rcvbuffer, int buflen, int
>timeout)
>{
>   unsigned long now;
>   unsigned long diff;
>   int i=0;
>
>   int bytes;
>   struct timeval tv;
>   struct timezone tz;
>
>   gettimeofday(&tv, &tz);
>   now = tv.tv_sec * 1000 + (tv.tv_usec/1000);
>
>   diff = 0;
>   while(diff < (unsigned long) timeout)
>   {
>       gettimeofday(&tv, &tz);
>       diff = ((tv.tv_sec * 1000) + (tv.tv_usec/1000) - now);
>       ioctl(fd, FIONREAD, &bytes);
>               
>           if(bytes > 0 && i < buflen)
>        {
>                   read(fd, rcvbuffer+i, bytes);
>                   i+=bytes;
>               }
>         usleep(1);
>   }
>
>   return i;
>}
>
>
>void rs_close()
>{
>       if(fd != -1 && fd != 0)
>               { close(fd); }
>}
>
>
>//-----------------------------------------------
>int main()
>{
>       int i,j,k;
>       unsigned char buf[512];         // buffer
>
>       if(rs_open() != 0)
>       {
>               perror("COM problem\n");
>               exit(EXIT_FAILURE);
>       }
>
>       j = sprintf(buf, "ATZ\r");
>
>       k = write(fd, buf, j); 
>    memset(buf, 0, sizeof(buf));
>    i = receive_data(fd, buf, sizeof(buf), 3000);
>    if(i > 0)
>       {
>       printf("RESPONSE: %s\n", buf);
>       }
>
>       rs_close();
>       return 0;
>}
>
>
>
>
>
>
>
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>  
>



------------------------ Yahoo! Groups Sponsor --------------------~--> 
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/CFFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU