Linux.com

sbm143

sbm143

  • Linux.com Member
  • Posts: 9
  • Member Since: 12 Feb 10
  • Last Logged In: 03 Mar 10

Latest Posts

Posted by
Topic
Post Preview
Posted
  • sbm143
    RE: Signal handling for 3 serial interrupt.
    Yes i have tested my code without modem also. It works fine.
    Link to this post 03 Mar 10

    Yes i have tested my code without modem also. It works fine.

  • sbm143
    RE: Signal handling for 3 serial interrupt.
    Not exactly but nearly about after every 6-9 seconds i am sending "AT" command
    Link to this post 02 Mar 10

    Not exactly but nearly about after every 6-9 seconds i am sending "AT" command

  • sbm143
    RE: Signal handling for 3 serial interrupt.
    [i]1.Are you able to receive data properly? i mean only receiving data packet from your GPRS device?[/i] Not always. But sometimes i get "AT" reply from modem.I have tested this code on Hyper Terminal (instead of GPRS modem) it works fine. Sometime it also fails.
    Link to this post 02 Mar 10

    1.Are you able to receive data properly? i mean only receiving data packet from your GPRS device?

    Not always. But sometimes i get "AT" reply from modem.I have tested this code on Hyper Terminal (instead of GPRS modem) it works fine. Sometime it also fails.

  • sbm143
    RE: Signal handling for 3 serial interrupt.
    Hi. In the source code I am just sending "AT" command and trying to check its "OK" response. My code is.... [code] #include #include #include #include #include #include #include #define BAUDRATE B9600 #define Modem "/dev/ttyAM1" #define _POSIX_SOURCE 1 /* POSIX compliant source */ #define FALSE 0 #define TRUE 1 /******************************************** Functions Prototype *****************************************************/ void Modem_Interface(void); void sig_handler(int status); void serial_cnfg(void); void modemdelay(void); void modemdelay1(void); /*************************************************************************************************************************/ /************************************************* Structures **********************************************************/ struct termios oldtio,newtio; struct termios oldtio1,newtio1; /*************************************************************************************************************************/ /********************************************** Global Variables *******************************************************/ int FD_Printer, FD_Modem, FD_CM; unsigned char sig_flag; int data; int fd,cashfd,c, res,cntr=0,virus=0; unsigned int CM_rply_Cntr=0; char CM_rply_Buf[250]; char rx_data,rx_cntr=0; /*************************************************************************************************************************/ void sig_handler(int status) { read(FD_Modem,&rx_data,1); //read(FD_Modem,CM_rply_Buf,100); //CM_rply_Buf[rx_cntr++]=rx_data; printf("rx_data=%c\n",rx_data); } void modemdelay(void) { unsigned int i=0,j; for(i=0;i<5632;i++) for(j=0;j<4234;j++); } void modemdelay1(void) { unsigned int i=0,j; for(i=0;i<632;i++) for(j=0;j<234;j++); } void serial_cnfg(void) { struct sigaction sa; sa.sa_handler = sig_handler; sa.sa_flags = 0; sa.sa_restorer = NULL; sigemptyset(&sa.sa_mask); sigaction(SIGIO,&sa,NULL); fcntl(FD_Modem,F_SETOWN,getpid()); fcntl(FD_Modem,F_SETFL,FASYNC); } void Modem_Interface(void) { char cmd[]="AT",data,enter=0x0D; unsigned int i=0; printf("Transmitting \n"); while(cmd[i]!='\0') { data=cmd[i++]; write(FD_Modem,&data,1); } write(FD_Modem,0x0D,1); } int main(void) { unsigned int i; while(1) { FD_Printer = open(Printer, O_WRONLY | O_NOCTTY ); if (FD_Printer <0) {perror(Printer); exit(-1); } FD_Modem = open(Modem, O_RDWR | O_NOCTTY ); //for modem if (FD_Modem <0) {perror(Modem); exit(-1); } serial_cnfg(); tcgetattr(FD_Modem,&oldtio); bzero(&newtio, sizeof(newtio)); newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0; newtio.c_lflag = 0; /* set input mode (non-canonical, no echo,...) */ newtio.c_cc[VTIME] = 2; /* inter-character timer unused */ tcflush(FD_Modem, TCIFLUSH); tcsetattr(FD_Modem,TCSANOW,&newtio); modemdelay(); for(i=0;i<248;i++) CM_rply_Buf[i]='\0'; rx_cntr=0; rx_data='\0'; //printf("\nIn Modem_Interface"); Modem_Interface(); modemdelay(); modemdelay(); } tcsetattr(FD_Modem,TCSANOW,&oldtio); return 0; } [/code] I am using wavecom GPRS ( Q24PL002) modem, with 9600 baud rate. I am setting everything in while loop beacuse whenever i used while(1) for only command transmission after some time signal handler did not worked.
    Link to this post 02 Mar 10

    Hi.

    In the source code I am just sending "AT" command and trying to check its "OK" response.

    My code is....


    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <termios.h>
    #include <stdio.h>
    #include<sys/signal.h>
    #include<sys/ioctl.h>

    #define BAUDRATE B9600
    #define Modem "/dev/ttyAM1"
    #define _POSIX_SOURCE 1 /* POSIX compliant source */
    #define FALSE 0
    #define TRUE 1

    /******************************************** Functions Prototype *****************************************************/
    void Modem_Interface(void);
    void sig_handler(int status);
    void serial_cnfg(void);
    void modemdelay(void);
    void modemdelay1(void);

    /*************************************************************************************************************************/

    /************************************************* Structures **********************************************************/
    struct termios oldtio,newtio;
    struct termios oldtio1,newtio1;

    /*************************************************************************************************************************/

    /********************************************** Global Variables *******************************************************/

    int FD_Printer, FD_Modem, FD_CM;
    unsigned char sig_flag;
    int data;
    int fd,cashfd,c, res,cntr=0,virus=0;
    unsigned int CM_rply_Cntr=0;
    char CM_rply_Buf[250];
    char rx_data,rx_cntr=0;

    /*************************************************************************************************************************/


    void sig_handler(int status)
    {
    read(FD_Modem,&rx_data,1);
    //read(FD_Modem,CM_rply_Buf,100);
    //CM_rply_Buf[rx_cntr++]=rx_data;
    printf("rx_data=%c\n",rx_data);
    }


    void modemdelay(void)
    {
    unsigned int i=0,j;
    for(i=0;i<5632;i++)
    for(j=0;j<4234;j++);
    }

    void modemdelay1(void)
    {
    unsigned int i=0,j;
    for(i=0;i<632;i++)
    for(j=0;j<234;j++);
    }



    void serial_cnfg(void)
    {
    struct sigaction sa;

    sa.sa_handler = sig_handler;
    sa.sa_flags = 0;
    sa.sa_restorer = NULL;

    sigemptyset(&sa.sa_mask);
    sigaction(SIGIO,&sa,NULL);

    fcntl(FD_Modem,F_SETOWN,getpid());
    fcntl(FD_Modem,F_SETFL,FASYNC);
    }

    void Modem_Interface(void)
    {

    char cmd[]="AT",data,enter=0x0D;
    unsigned int i=0;
    printf("Transmitting \n");
    while(cmd!='\0')
    {
    data=cmd[i++];
    write(FD_Modem,&data,1);
    }

    write(FD_Modem,0x0D,1);
    }


    int main(void)
    {
    unsigned int i;

    while(1)
    {

    FD_Printer = open(Printer, O_WRONLY | O_NOCTTY );
    if (FD_Printer <0) {perror(Printer); exit(-1); }

    FD_Modem = open(Modem, O_RDWR | O_NOCTTY ); //for modem
    if (FD_Modem <0) {perror(Modem); exit(-1); }

    serial_cnfg();

    tcgetattr(FD_Modem,&oldtio);
    bzero(&newtio, sizeof(newtio));

    newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
    newtio.c_iflag = IGNPAR;
    newtio.c_oflag = 0;
    newtio.c_lflag = 0; /* set input mode (non-canonical, no echo,...) */
    newtio.c_cc[VTIME] = 2; /* inter-character timer unused */

    tcflush(FD_Modem, TCIFLUSH);
    tcsetattr(FD_Modem,TCSANOW,&newtio);

    modemdelay();

    for(i=0;i<248;i++)
    CM_rply_Buf='\0';

    rx_cntr=0;
    rx_data='\0';

    //printf("\nIn Modem_Interface");
    Modem_Interface();

    modemdelay();
    modemdelay();

    }

    tcsetattr(FD_Modem,TCSANOW,&oldtio);
    return 0;


    }





    I am using wavecom GPRS ( Q24PL002) modem, with 9600 baud rate. I am setting everything in while loop beacuse whenever i used while(1) for only command transmission after some time signal handler did not worked.

  • sbm143
    RE: Signal handling for 3 serial interrupt.
    Thanks for your suggestion. I have also one more problem in signal handling. I have connected a [b]GPRS modem[/b] to [b]UART1 (serial port).[/b] In the code i am just sending [b]"AT" [/b]command continuously and trying to check its reply. But problem is that [b]sometimes I get reply "OK" and sometimes not. [/b] Also [b]after some time my code is does not get interrupted even though there is reply from modem.[/b]. I have checked this using Hyper Terminal. Please help me out what is the prolem?
    Link to this post 27 Feb 10

    Thanks for your suggestion.

    I have also one more problem in signal handling. I have connected a GPRS modem to UART1 (serial port).
    In the code i am just sending "AT" command continuously and trying to check its reply. But problem is that sometimes I get reply "OK" and sometimes not.

    Also after some time my code is does not get interrupted even though there is reply from modem.. I have checked this using Hyper Terminal.

    Please help me out what is the prolem?

  • sbm143
    Signal handling for 3 serial interrupt.
    Hi all, I have 3 different devices[b] Dev1, Dev2 & Dev3 [/b]connected to [b]UART 1, UART 2 & UART 3 [/b]respectively. I am using these 3 devices alternatively. I want to [b]write signal handler for these 3 devices interrupts[/b]. I am able to handle one signal handler at a time. But problem is that when I have tried to write signal handler for other (means [b]t[/b][b]wo signal handler at a time for SIGIO signal[/b]), my programs does not work. Can anybody tell me how to solve this problem? Please help me. Thanks
    Link to this post 22 Feb 10

    Hi all,

    I have 3 different devices Dev1, Dev2 & Dev3 connected to UART 1, UART 2 & UART 3 respectively. I am using these 3 devices alternatively.
    I want to write signal handler for these 3 devices interrupts. I am able to handle one signal handler at a time.

    But problem is that when I have tried to write signal handler for other (means two signal handler at a time for SIGIO signal), my programs does not work.

    Can anybody tell me how to solve this problem?

    Please help me.

    Thanks

  • sbm143
    Display Characters on Screen
    Hi all, I am trying to display the characters getting from keyboard, on screen. Currently i am using TS 7260 board (linux ported on it) with [b]PC/104[/b] bus. I can access [b]PC/104 bus with 8/16 bit [/b]mode. I am able to display images on the screen (size [b]640 X 480[/b]), but not characters. Can anybody help me how to do it? Please help me. Thank you.
    Link to this post 19 Feb 10

    Hi all,

    I am trying to display the characters getting from keyboard, on screen.
    Currently i am using TS 7260 board (linux ported on it) with PC/104 bus. I can access PC/104 bus with 8/16 bit mode.
    I am able to display images on the screen (size 640 X 480), but not characters.

    Can anybody help me how to do it? Please help me.

    Thank you.

  • sbm143
    RE: Problem in reading data from serial port.
    Thank You very much for your reply:) . I got solution for serial programming in terminos.h.
    Link to this post 19 Feb 10

    Thank You very much for your reply:) .
    I got solution for serial programming in terminos.h.

  • sbm143
    Problem in reading data from serial port.
    Hi all, I am writing code for reading & writing the data from serial port (UART of ARM Processor). But i am facing a problem in reading. As written in man page the [b]read()[/b] call returns the character till it will get [b]"Enter/Carriage return" [/b]or [b]"EOF"[/b]. I am interfacing the [b]GPRS modem[/b] on this serial port. So from Modem there is no way to get me "Enter/Carriage return" or "EOF". Because of this read() gets blocked. [i][b]Is there any other way to just read the received characters without EOF & returns that characters?[/b][/i] Please help me for this.
    Link to this post 18 Feb 10

    Hi all,

    I am writing code for reading & writing the data from serial port (UART of ARM Processor).
    But i am facing a problem in reading.

    As written in man page the read() call returns the character till it will get "Enter/Carriage return" or "EOF". I am interfacing the GPRS modem on this serial port. So from Modem there is no way to get me "Enter/Carriage return" or "EOF".

    Because of this read() gets blocked.

    Is there any other way to just read the received characters without EOF & returns that characters?

    Please help me for this.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board