Exsrtacting data


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default Exsrtacting data

    Can anyone please help
    I am trying to exstract data from a string of serial data from a sms modem
    THE string
    ^SMGL: 1,"REC UNREAD","+27829554322",,"08/04/20,17:12:09+08"
    test

    I need to exstract the cell number from this after reading some posts recomending debugin
    i tried hserin the idea is to use a interupt and as soon as data comes in decode it, test the sell number and if it is a recognized number ecsecute the command in the message field
    This is the command i thought would work but my program hangs
    HSERIN [WAIT("SMGL:"), SKIP 18 , V5]

    Any help would be appreciated

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    so ^SMGL: 1,"REC UNREAD","+27829554322",,"08/04/20,17:12:09+08" is EXACTLY what you see in hyperterminal or else terminal?

    27829554322 should be the number to extract number by number and then compare with a specific one or a table of?

    Did you tried with STR and a BYTE array?

    Did you tried your hardware with a PC to PIC communication (with MAX232)?
    Last edited by mister_e; - 20th April 2008 at 17:14.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi there,
    I am using a serial port on my pc sending the data via an rs232 chip to a 16f913
    Below is my code that shoed reply with the message number and the cell number but nothing happens any suggestions
    [CODE]
    INCLUDE "MODEDEFS.BAS"

    DEFINE OSC 20 ' Define crystal as 20Mhz

    '*Serial port Setup 9600 8N1*
    DEFINE HSER_BAUD 9600 ; 9600 Baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically

    '*ADC setup*
    DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
    DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
    DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS

    'This Part set PORTA 0-5 an analog inputs
    ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = %00011111 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs
    ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913

    TRISC = %10000000 'Set PORTC for serial coms and pins as output
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2

    INTCON = 0 ;Disable interrupts


    V1 var WORD
    ID var byte[28]

    PORTC = 0

    loop:
    'ADCIN 0,V1
    HSERIN [WAIT("^SMGL:"),SKIP 1 ,str ID\28]
    HSEROUT ["MES NO:",dec ID[0],10,13]
    HSEROUT ["CELL NO:",dec ID[17],dec ID[18],dec ID[19],dec ID[20],dec ID[21],dec ID[22],dec ID[23],dec ID[24],dec ID[25],dec ID[26],10,13]

    goto loop

    END
    [END CODE]

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,121


    Did you find this post helpful? Yes | No

    Default

    Do you have a level translator between PIC-Phone? Like a MAX232?

    Ioannis

  5. #5


    Did you find this post helpful? Yes | No

    Default

    A this stage i use my PC to send the data to the pic via a SP232ACP chip

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it works here using...
    Code:
    loop:
            'ADCIN 0,V1
            HSERIN [WAIT("^SMGL:"),SKIP 1 ,str ID\28]
            HSEROUT ["MES NO:",ID[0],10,13]
            HSEROUT ["CELL NO:",_
                    ID[17],iD[18],ID[19],ID[20],ID[21],ID[22],_
                    ID[23],ID[24],ID[25],ID[26],ID[27],10,13]
            
            goto loop
    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2533&stc=1&d=120888300 3">
    Check your Config fuses setting, make sure you have HS_OSC enabled.
    Attached Images Attached Images  
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thanks got it working ,needs to remember to copy all include files next time i format my pc

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts