Comunicating External hardware device

In 9 days, i have to give an answer to a FIRM if i'm willing to Upgrade a software they are using
from DOS to WIN32.
the existing software were written some years ago in C for DOS. there is no way\chance to make
the company who wrote it give me the source code, nor giving me any hints of the basic concepts
regarding anything.
i've been observing the existing software for 3 days. my impression is that i can make a better software

(WIN32) with not much effort.
however, 1 issue is totally Unknown to me, and i have no idea how to START dealing with it, since i've

never done that before.
that is the <<Comunicating between My program and an EXTERNAL hardware device>>
here is a short description :

the existing software is comunicating with External Device through COM1.
the external device is a BOX which is connected to 3 acustic sensors that record some mechanical
equipment noises. each record recorded holds 3 values from those 3 sensors.
now, the documentaion says that the BOX saves up to 100 last records.
upon starting some function in the software - the BOX is clearing all records and starts transmiting
the computer's  COM1 new records. after the protocol validate that a record has been accepted properly -

the BOX delete it.
SO, what i need is :
1. How can i implement the Command from the Softwrare to BOX to clear and start transmitting ?
2. How do i know the FORMAT i accept from COM1, so i can process it in the software ?

if i had the existing C source code - i could get it from there. since i don't - can i make it ?

unless you have complete and full positive answer - just post COMMENTS plz, otherwize - i'll have to
automatically reject in order to unlock the Q for more comments.
Thank you.

Who is Participating?
mark2150Connect With a Mentor Commented:
If the client is going to put unrealistic conditions on you then they have to accept low quality/slow work.

There are three aspects to any project, Time to complete, cost, quality. Your client can only specify two and the third will fall where it may.

Using a tap on the line does work. If you have them run the gear thru it's normall functional paces you should see everything you need. Force exceptions at the remote hardware and see how it generates alerts.

If the supplier of the gear has set a price, then that is your upper budget limit.

Explain to the client the problems and tell them up front "This ain't gonna be CHEAP!" Any delays in giving you access to the gear are going to delay the delivery date by an equal amount. Period. Put *THAT* into the contract.

You can rent a "sniffer" for serial line diagnostics (hp sells them) Have them order one for you, again as part of the contract. Either that or tell them that you'll have to develop a check tool *FIRST* and then you'll be able to give a better answer once you've seen the data stream. Naturally, they have to pay for this even if they decide not to go forward.

Realistically, this isn't *THAT* hard to do. I did this exact thing with a banking system and wound up writing a DEC-VT220 emulator without knowing it! :-)

The vendor will not normally make their equipment difficult to interface to as this will prevent them from developing *their* internal software. Sometimes you'll get binary data in a RS-232 stream, but more often than not the command set is quite obvious.

Also, running their DOS app thru a string extractor might reveal quite a bit about the command set. Once you have the basic command syntax chances are there is a table embedded in their code with *ALL* commands in it. If you know what to look for it's not to hard to find.

I one time had to rewrite a video capture card driver in .ASM from inspecting a compiled QBASIC program. We had no info on the I/O addresses, etc. but OUT DX, AL's are fairly easy to spot in the code!

As long as they understand that a "reverse engineer" task takes time and will not be 100% perfect on the first try, then go for it.

If you get it working (mostly) and then sometime down the road they trigger a fault or change a config setting on the hardware that suddenly breaks your code the client needs to understand that this can (and likely will) happen and that they should be prepared for this and be willing to pay you additional for the extra work. This is NOT like a latent bug where you should fix it free, but rather it's an "undocumented feature" than is an *enhancement* and therefore billable time.

If you make this clear to the client and they still want to go ahead then you should be fine. If they balk at the price, shrug your shoulders and tell them to *buy* the expensive version from the vendor.

Can you get protocol documentation for the BOX?
AnswerTheManAuthor Commented:
:)if i could - i would not be posting this Q....
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

You could use a serial tap to watch the communications flow while the program is running.  Tap the line from another PC and open HyperTerminal to view the data stream between the BOX and the other computer.  You can change the Hyperterminal settings until you figure out what the hardware settings are.  By viewing the data stream, maybe the software protocol will expose itself too.
Based on what I read, the BOX sends information and you have no way of knowing what format that information is in.

If this is the case, the data will come back in one of three ways.
1.) The information will come back in some fashion that you will be able to recognize and extract the data (trial and error).
2.) The information will come back in a form that is highly encrypted and you will never understand what is what.
3.) The information will come back in a form that while not encrypted is not easy to see the data from everything else coming back.

As for having your software command the BOX to dump the data, the documentation must specify what commands are required.

After all this, it sounds like a straight forward COM1 function to send and recieve data.

The other thing that might help all the experts to give you a better answer would be the manufacturer of the BOX.

I wish I were you, this sounds like the kind of challenge I enjoy.

Good Luck

Use the the Microsoft Comm Control to communicate out the port to start or stop the process and to receive the infromation.
You need two taps. One for inbound traffic and one for outbound Your monitoring system will need both com port RX channels and neither TX channel.

Write a little program (preferably in DOS) that alternately looks to both RX ports and prints what it finds to the screen. Have it use two colors to distinguish from COM1 and COM2 data.

(I've actually done this to decode a data stream)

Then it's simply a matter of putting the existing system thru it's paces to see what the command/response sequences are. Once you know these you can easily write your VB app using the MSCOMM control to send the same sequences and expect similar responses.

Problems occur if your testing isn't complete and you don't determina *ALL* commands.

This is not conceptually hard to do (and I've done) but it can take an inordinate amount of fiddling to get it right based on empirical observations like this.

AnswerTheManAuthor Commented:
tnx for responses given so far.
anymore comments will be welcome.
However, as i expected, this part going to be the problematic one, since as mark2150 mentioned - i can never be sure i implemented all existing commands and functinality.

evaluating this Q will take time, since the existing system is heavily used round the clock, and if i decide to make it - i'll have to disable them of using it for my "trial and error" experiments.
if i'll make it - i will be able to evaluate your comments.
one more thing :
i'll apriciate if you'll post comments regarding other comments given. maybe this can lead for agreed first priority action that i should start with, when i'll come to that.

thanks again
Of course you could always demand a copy of the manuals and support documentation as a condition of taking the job...

AnswerTheManAuthor Commented:
hmmm... it's not that simple, M.
that firm asked the software-hardware company that built BOTH the exisiting software AND the hardware to make the upgrade + software improvments.
the PRICE that that firm demandad was much too high, so they came to me (i made for them a lot of projects before).
of course i can demand the protocol, and maybe i'll put it as a condition, but, you see, the chances to get it are poor....
the problem of not having free access to the system whenever i need - is another obstecle...
what would you do ? i don't really *NEED* that job now. i have plenty, although this one seems a fast and easy one (exept the above problem), good money, and no crucial time-limit\deadline to deliver.
AnswerTheManAuthor Commented:
mark2150: yes. that's what i had in mind.
BUT, i think i'll demand another oportunity to check the system before giving ANY answer. in this oportunity - i'll try Erick37 suggestion, which is handy and won't request any special preperations from me.
IF (using the Hyperterminal) i'll get a clearer picture THEN
  i may take it straight.
  i probebly be telling them what you said.

...........thank you.
IF you can get your hand on and old copy of PCPlus for DOS, it does a great job of displaying the CONTROL CHARACTERS that are quite often used to signal the START and END of a message...
many devices use, for example, STX (which is Chr$(2) in VB) to signal the start of a message.
You may have to use two PC's to capture the data from each side of the conversation.......
This type of project is not impossible, but it is MUCH easier if you can spend a day or two with the equipment ;-)

AnswerTheManAuthor Commented:
ok. here it is :

is what i've used to get it with.
it's a good tool, and i could get about 5% of what i was after in 4 days (5 hours each day) of joining the team that works with the current system.

there are about 80 settings available from software to BOX, each of them have to tracked. i've got 4....

so - i've explained to the executives there that tracking the 95% remaining will take a LONG LONG time, when working "with" the team. since i don't work for nothing - it'll cost them less to try get the complete protocol, source code, or order a new software from the original source.

i'm waiting for their decision.
as for awarding points for this Q :

since i've never did such thing concerning hardware before - i was hoping to get a MAGIC solution, and obviously disapointed.
however - facing the materia, i know i was naive and therfore - i apreciate all comments.
Mark2150 showed the most willingness and readiness to help (byond the thecnical aspect), so, i hope nobody will gut hurt of him getting the points.
thank you all.
Thank you sir!

All Courses

From novice to tech pro — start learning today.