Combining Strings...
starion
Posts: 27
I racked my brain, tried 30 different ways of doing it and still couldn't get it to work. Here's what I'm trying to do in a nutshell:
Here is the data I am working with:
counter VAR WORD ' A number from 0000 to 9999.
fixedword DATA "theword" ' Just a word.
I am trying to created a concatenated string with the end result being:
"0000theword" and each increment of the counter would be "0001theword", "0002theword" and so on.
Ultimately I will be sending this string out a serial port, but for now, I would be happy just to get them combined and output them as a DEBUG command. I'm sure this is an easy thing, but I'm fairly new to this and haven't quite got my syntax down.
Quick word of advice anyone? This is a BS2.
Post Edited (Starion) : 11/27/2005 4:04:20 PM GMT
Here is the data I am working with:
counter VAR WORD ' A number from 0000 to 9999.
fixedword DATA "theword" ' Just a word.
I am trying to created a concatenated string with the end result being:
"0000theword" and each increment of the counter would be "0001theword", "0002theword" and so on.
Ultimately I will be sending this string out a serial port, but for now, I would be happy just to get them combined and output them as a DEBUG command. I'm sure this is an easy thing, but I'm fairly new to this and haven't quite got my syntax down.
Quick word of advice anyone? This is a BS2.
Post Edited (Starion) : 11/27/2005 4:04:20 PM GMT
Comments
Post Edited (Tibot) : 11/27/2005 4:28:13 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/27/2005 5:01:42 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
So if you are going to be doing alot of it you may want to convert Jon's program to use RAM memory instead of EEPROM memory. If you leave out the display and pause commands in that one you can burn up your eeprom memory locations 0 through 3 in about an hour. On higher stamps running faster and only 100,000 writes could bee poof before you blink.
I could be wrong about this , if so please correct me....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
Here's a "safe" version that is RAM and program space efficient (which is critical in small controllers like BASIC Stamp -- in my opinion using RAM for strings is a huge waste of resources); pass the value you want to print in "temp" and the string you want to append in "eePntr."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/27/2005 6:09:26 PM GMT
DO WHILE COUNTER<10000
SEROUT [noparse][[/noparse]DEC4 counter]
SEROUT [noparse][[/noparse]"theword",CR]
counter=counter+1
LOOP
Once I realized that the serial device on the other end doesn't know whether I used one or six SEROUT commands, it all appears continuous until a CR is sent, my thinking cleared up a bit. If you are at all interested in this project, read on, details below:
BTW, this is my FIRST project with the BS2. I can't believe I actually got it working about 1:30AM. Here's the scenario:
My company sells, services, and installs a brand of business telephone system (among a zillion other things we do related to technology). When we take over a new customer's system, we have no idea what the 4-digit code is to get into the programming on the phone switch.
The phone system has a DB9 serial port for PC hookup and programming. When you hook it up, press return in a terminal, you are presented with a password prompt. If you enter a wrong password, it simply does nothing. However, if you enter the correct code, you get a specific prompt that I wait for with SERIN.
So, I built a very simple BS2 circuit using the professional development board that simply tries every number from 0000 to 9999 with "theword" appended to the code. I have discovered that you can crack any code inside of 20 minutes, and usually shorter depending on how close the actual code is to 0000.
The code I wrote is considerably more complex than my example above, accounting for things like no response from the phone switch, using a 7-segment display to indicate working status, and percentage complete, as well as a way to display the cracked code, all on one 7-segment display.
It works like a champ, has correctly cracked every code I tried so far. Future additions might be auto-baud detect AND...(speeding up the search)
leading to my next related question which I will start in a topic of its own entitled "Guessing a number".
Post Edited (starion) : 3/4/2007 3:33:05 PM GMT
This points out something else. Almost any security system can be hacked. What the security system does is slow down the hacker (or raise flags "Hey! Somebody just tried 100 different PIN numbers!") so it takes long enough the hacker can be apprehended.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The issue here is whether anybody (besides myself) would find any value to hacking the installer code. Only myself and possibly other dealers who sell and maintain this type of system. I have no malicious intent here, simply something that makes my job easier. I suppose someone could wreak havoc with this kind of tool.
The other consideration is that this method requires physical access to the switch. Although I am working on a software cracker to perform the same function remotely.
·· My point was directed more at Allan's comment about security.· I guess my point was, even though it is quite lax in this device, you can't expect that everywhere.· For example, in the movie The Terminator (I think 3) they show the kid hacking the ATM machine using the same exact method you're using.· That wouldn't work on any ATM I have ever seen.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...