PDA

View Full Version : Slicing a string into different parts


tomt
07-14-2010, 07:06 PM
Hello all,

I'm tying to parse a sting into three smaller strings. I do this in three steps, but after the last step all three strings are equal to the last string. heres my function

def LinkAckWithName(data):

print data

# Parse Senders Address
index = 0
while data[index] != '{':
index = index + 1
if index > 10:
break
SendersAddress = data[index+1:index+7]

# Parse DataType
index = 0
while data[index] != '[':
index = index + 1
if index > 20:
break
DataType = data[index+1:index+4]

# Parse Name
index = 0
while data[index] != '<':
index = index + 1
if index > 30:
break
Name = data[index+1:index+11]

print SendersAddress
print DataType
print Name

for the Input string "{123456}[001]<abcdefjhij>". I get

abcdefjhij
abcdefjhij
abcdefjhij

instead of

123456
001
abcdefjhij

I know that each individual section works, because I tried printing the result after each section.

I know that SNAPpy has some limitations when it comes to string manipulation, but I'm sure there must be a way to do this.

Thanks,

Jheath
07-14-2010, 10:09 PM
If you are using an older version of firmware (2.1) then there are limitations to string manipulation. This was due to the use of static buffers (one for strings, one for string concatenations, and one for string slices).

Newer versions of SNAP (2.2 and later) incorporate true dynamic strings and thus remove a number of limitations. The size and number of these dynamic strings varies with the hardware implementation you are using (Synapse RFE, ZIC2410, etc...)

For example, in SNAP 2.4.9, the RF100 RFEngine supports 7 small strings (<8 characters) and 6 larger strings (< 62 characters).

More information for all hardware platforms can be found within the SNAP Reference Manual.

An updated Portal installation will include the latest firmware and can be downloaded for free from the "Latest Releases" section of this forum (http://forums.synapse-wireless.com/showthread.php?t=9).