Home NetLinx Studio

String Receive Manipulation

cmatkincmatkin Senior MemberPosts: 86
Hello there.

I am receiving the following strings from a polycom device (each line has a CR and LF at the end)

abk 0. Boardroom spd:384 num:33.04.92389306
abk 1. Boardroom IP spd:4096 num:vc.melbourne.com.au

What I would like to do is capture the following information as strings from the above data.
_Address[1].cName = Boardroom
_Address[1].cSpeed = 384
_Address[1].cNumer= 33.04.92389306
_Address[2].cName = Boardroom IP
_Address[2].cSpeed = 4096
_Address[2].cNumer= vc.melbourne.com.au

The _Address index is set by the abk number. (eg: if abk 0, then index will be 1)

Does any one have functions to do this?

Regards
Craig

Comments

  • NMarkRobertsNMarkRoberts Junior Member Posts: 455
    Compiled but not tested and lacking error checking.
    define_type 
    
    struct tAddress
      {
      char cName[100]
      char cSpeed[100]
      char cNumer[100]
      }
    
    define_variable
    
    tAddress _Address[100]
    char sReceived[100]
    integer nSubscript
    char sChunk[100]
    
    define_start
    
    (* 
    abk 0. Boardroom spd:384 num:33.04.92389306 
    abk 1. Boardroom IP spd:4096 num:vc.melbourne.com.au
    *)
    
    if (find_string(sReceived,'abk ',1))
      {
      (* Get the subscript to the _Address array *)
      remove_string(sReceived,'abk ',1)
      nSubscript = atoi("sReceived[1]") + 1
    	
      (* Get the name *)
      remove_string(sReceived,'. ',1)
      sChunk = remove_string(sReceived,' spd:',1)
      _Address[nSubscript].cName = left_string(sChunk,length_string(sChunk) - 5)
    	
      (* Get the speed *)
      sChunk = remove_string(sReceived,' num:',1)
      _Address[nSubscript].cSpeed = left_string(sChunk,length_string(sChunk) - 5)
    
      (* Get the number *)
      _Address[nSubscript].cNumer = sReceived
      }
    
  • cmatkincmatkin Senior Member Posts: 86
    Thanks heaps.
    This is a great starting point. It had me stumped.
    I'm just changing how the abk 0. bit works. the abk range is 0 to 999 (3 chars).
    Thanks again.

    Regards
    Craig
  • JustinCJustinC Junior Member Posts: 74
    Polycom is tricky.

    One thing you need to know about the way it reports back the phonebook is that if you have it filled out with an IP number and a ISDN number it returns the same abk entry for both numbers.

    So if you have an entry called Boardroom and have a telephone number, a isdn number and a IP number they will all come back on abk 1.


    Its been awhile, but Im pretty confident this is the way it reports back which makes it difficult to use the index. I would try to put in an entry and give it multiple fields and then see how the phonebook reports. I ended up writing my own speeddial codeblock that stores all speeddial numbers in a text file on the controller and then the customer could just copy and paste the text document on all the controllers not having to enter them manually.
  • cmatkincmatkin Senior Member Posts: 86
    Thanks,
    You are correct about the address book.
    What a pain. For the time, we are making sure that the address book holds only one number per entry.
    We have to use the inbuilt addressbook, as we are combining 10+ codecs to use the global addressbook functions.

    Lastly, I found that the String handley in the data events did not trigger enough. The codec justs spits the data out all at once.

    Thanks for your help and information.

    Regards
    Craig
Sign In or Register to comment.