Re: String Manipulation and a Need for RS-232
Martin McCormick wrote:
I have used GCC C for years to write a number of
programs for work and play and it is great but I think I am
needing to branch out a bit as my latest project is causing me
I have a scanner radio receiver that uses RS-232 to
communicate with the computer and I got that part of things to
work well. Here's the problem. The radio receives commands via
CSV strings as in sin,abc,def,1,7,8,etc,etc\r and its output is
also CSV as in sin,err\r or sin,lot,of,variables,to,read\r
I also got that working such that it could read the
response and break out all the CSV variables in to separate
strings. In other words, it does work and with gdb, one can
trouble-shoot it fairly easily.
I have this nagging feeling, though, that there may be a
better way to write this program since C is not as good at
string manipulation as some other languages. In my program, you
have to do a lot of grunt work just to be sure that the 15TH
field really is the 15TH field in the string one is sending out.
In the standard set of tools that are free and found on
most Unix systems, which language such as perl, python, etc can
handle rS-232 gracefully and do strings without having to
reen vent the wheel?
I had this epiphany after spending most of last weekend
and early this morning digging through this program I had
written only to find that the reason things weren't working was
that it appears that I sent out a CSV string with some of the
variables shifted by a couple of spaces. I can easily fix that,
but it got me to thinking.
If I can do all of this within one language, including
the RS-232 coms, that will be great.
If I were in your situation, I would convert your C programs to C++
(changing <prog>.c to <prog>.cpp) and use Qt. I use it many places just
for its string manipulation and Qt has great documentation.
Just install libqt4-dev, qt4-dev-tools, qt4-qmake and qt4-doc.
Create a <prog>.pro file for your <prog>.cpp and run 'qmake -o Makefile
<prog>.pro' and then 'make' and away you go.