Shop OBEX P1 Docs P2 Docs Learn Events
Parsing an MDMF CID String ? — Parallax Forums

Parsing an MDMF CID String ?

skynuggetskynugget Posts: 172
edited 2009-03-26 18:22 in BASIC Stamp
Hey all, i have a bs2 hooked up to an old caller id chip and im having trouble picking out all of the serial data.

the MDMF format is as follows

Each byte is in HEX.
# 80 - Message type word, 80 indicates MDMF
# 20 - Length of data, 32 bytes in date,time,name and number
# 01 - data type, 1 = date & time
# 08 - length of date and time, 8 bytes
# 30,33 - 03, March
# 32,34 - 24, 24th day
# 30,39 - 09, hour
# 30,32 - 02, minutes (9:02am)
# 07 - data type, 7 = name
# 08 - length of name, 8 bytes
# 4A - 'J'
# 4F - 'O'
# 48 - 'H'
# 4E - 'N'
# 20 - ' ' (space)
# 44 - 'D'
# 4F - 'O'
# 45 - 'E'
# 02 - data type, 2 = phone number
# 0A - length of phone number, 10 bytes
# 38 - 8
# 30 - 0
# 30 - 0
# 35 - 5
# 35 - 5
# 35 - 5
# 31 - 1
# 32 - 2
# 31 - 1
# 32 - 2
# 7D - Checksum


I'm trying to use this code to grab the first 9 bytes of the name, then the phone number at 2400bps.



 SERIN DataIn,CIDBaud,1000, NoNumber,[noparse][[/noparse]WAIT($07), SKIP 1,STR NameData\10]  'wait for hex 7 name header

 SERIN DataIn, CIDBaud,1000, NoNumber,[noparse][[/noparse]WAIT($02), SKIP 1, STR CIDData\10]      ' wait for  hex 2 phone header

  DEBUG STR NameData,CR
  DEBUG STR CIDData,CR




my guess is this routine is to slow to wait for the second header, if i take out the timeout it just hangs forever. is this possible for the bs2 to do this?



thanks so much!

Post Edited (skynugget) : 3/22/2009 6:24:42 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-03-22 17:32
    You might be better off trying to capture the entire string and then parsing the data. How big can the data string be and is it repeated more than once?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-22 17:32
    What happens if the name is shorter than ten characters? Won't the $02 header get gobbled up in NameData?

    -Phil
  • skynuggetskynugget Posts: 172
    edited 2009-03-22 17:49
    stephen, i only have 1 shot to grab it, and i cant find a definite answer as to how long the name data could actually be

    phill, you are correct it will get garbled, but my name is longer then that, and i figured i'd cross that bridge once i can crab all the data :>
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-22 20:18
    I agree with Stephen: grab the whole string first, then parse it. But you won't be able to do this with a BS2, since variable space is so limited. A BS2p, BS2pe, or BS2px would work though, since you can stream up to 126 bytes into scratch pad RAM using SPSTR.

    -Phil
  • skynuggetskynugget Posts: 172
    edited 2009-03-23 02:36
    i was afraid that would be the answer. id hate to waste a bs2pfor such a simple task. is there maybe a uart that would be easy to use?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-03-23 18:17
    Hi , due to the limitations of variable space you might opt for a processor with scratchpad ram which would certainly allow you to capture a name string of any length you·will encounter .

    One thing I would consider though is that instead of trying to "skip" the two bytes that contain the string lengths of the name and number is to read them and use them to your advantage.

    Here is a piece of code you can use with the BS2 that will read a name as large as 14 characters and a number as large as 10 , any larger strings will get truncated . All variable space is used by the three arrays so if you need additional variables you will have to offload the arrays and re-use some of the array space . The array len is used to read the string lengths to allow for variation in size.
    Name VAR Byte(14)
    Tel VAR Byte (10)
    len VAR Byte(2)
    SERIN DataIn,CIDBaud,1000, NoNumber,[noparse][[/noparse]WAIT($7),len(0),STR Name\len(0),WAIT($2) ,len(1),STR Tel\len(1)]
    len(0)=len(0) MAX 14
    len(1)=len(1) MAX 10
    

    You can use a similar code with scratchpad ram .

    Jeff T.
  • skynuggetskynugget Posts: 172
    edited 2009-03-23 20:00
    yeah i still run into the problem of missing the $02 header though :<
  • skynuggetskynugget Posts: 172
    edited 2009-03-26 17:38
    yeah and i just figured out why, the string coming from my phone company is different then the example!!!! if you are ever messing with caller id, in the us (verizon at least) the example would be:


    the MDMF format is as follows

    Each byte is in HEX.
    # 80 - Message type word, 80 indicates MDMF
    # 20 - Length of data, 32 bytes in date,time,name and number
    # 01 - data type, 1 = date & time
    # 08 - length of date and time, 8 bytes
    # 30,33 - 03, March
    # 32,34 - 24, 24th day
    # 30,39 - 09, hour
    # 30,32 - 02, minutes (9:02am)
    # 02 - data type, 2 = phone number
    # 0A - length of phone number, 10 bytes
    # 38 - 8
    # 30 - 0
    # 30 - 0
    # 35 - 5
    # 35 - 5
    # 35 - 5
    # 31 - 1
    # 32 - 2
    # 31 - 1
    # 32 - 2
    # 07 - data type, 7 = name
    # 08 - length of name, 8 bytes
    # 4A - 'J'
    # 4F - 'O'
    # 48 - 'H'
    # 4E - 'N'
    # 20 - ' ' (space)
    # 44 - 'D'
    # 4F - 'O'
    # 45 - 'E'
    # 7D - Checksum

    the number comes first. the bs2 is fast enough to parse it though. it works great!! i figured it out by finally unsealing my bs2px and reading out the raw hex from my caller id chip... duh


     SERIN DataIn,CIDBaud,4000, NoNumber,[noparse][[/noparse]WAIT($02),len(0),STR NumberData\len(0),
                                           WAIT($07),len(1),STR NameData\len(1)]
    
      len(0)=len(0) MAX 10
      len(1)=len(1) MAX 10
    
    



    thanks!

    Post Edited (skynugget) : 3/26/2009 5:45:49 PM GMT
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-03-26 18:22
    Well·done, always nice to figure these things out and good learning experiences.

    Jeff T.
Sign In or Register to comment.