Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RS232 Help

Status
Not open for further replies.

blahblah

Computer
Mar 20, 2003
2
0
0
GB
Hi

I have a problem as i need to write a simple comm's program to send one hex string to the serial port.. Ideally i would like this program to be a single .exe file that when run just sends the hex string and closes the port..

Also

-It needs to run in win2k
-It needs to run hidden but i assume that if it was an .exe i could just use hidden32.exe to hide it..
-I might need to send a different hex string in the future so it would be best to have an easy source file to edit..

Thats it really... I have searched and searched the net but cant seem to find any pre-made program that would be suitable... However i did find a few C++ and VB libraries that might be able to be edited...

I dont have any idea of what would be the best lanugage to use as i dont have any particular knowledge of any one lanugage but am willing to give it a go... If u have any input on the best lanugage and other info places to look or even a program that u have come across on your travels that might do the job or even a source code it will be apperciated..

And if u are able to reply please the more indepth the better...

Thank You :)
 
Replies continue below

Recommended for you

Hi melone

I have a basic understanding of computer programming languages... i.e Pascal, C++, Cobal, ASM, i never liked programming i only ever done what i had to do to graduate. I graduated about 5 years ago so and besides java programming i dont really do anything other maybe edit a few source files for linux... Not to mention in my opionion it takes someone interested and special to be a good programmer and i am not...

The project is to control a simple rs232 device, I need to send the following to the serial port... 3FH 60H 80H 4EH 00H... Any advise would be apperciated


With Thanks
 
If you have to send one fix text, you can just as well send
anything and replace/actuate the desired string.

The info content of a fix string is 1 bit ( received/not received) <nbucska@pcperipherals.com>
 
I have programmed multiple RS232 applications and would suggest using C. You can find example code and the appropriate usage in the Microsoft MSDN libraries. Specifically at
You will have to use the windows.h header.

You will have to use the CreateFile() function to initialize the serial port.

You will have to use the WriteFile() function to write the hex byte to the port.

Hope this helps.

Kris
 
in DOS and some other OSs you can probably do this from command line/script file, right?
from an ancient DOS book:
MODE will set the COM parameters
ECHO (string) > COM1
or the similar...

These commands exist in Win XP Home, so I suspect that they exist in Win 2K as well.

don't need no stinking .exe file!

Jay

Jay Maechtlen
 
How is the exe program supposed to be called?
If the serial communication is part of a larger program, why not use it to send the codes.
Sorry if this is off base, but a little more info in what you are rying to accomplish might lead to better solutions than a standalone exe.
 
If you want a stand-alone code I need the RS 232 parameters
(baudrate, COM1 or 2, parity, number of bits, text)
AND an E-mail address.


<nbucska@pcperipherals.com>
 
I'm not shre how to send you the program, but I was able to whip up a Visual Basic version that utilizes MSCOMM. It compiles to a small binary that only sends your specified string out com port 1 and ends.

It basically is only one module but there must be a form to contain the MSCOMM control.

'===================
Option Explicit

Const theString = &quot;&h3F&h60&h80&h4E&h00&quot;

Sub Main()
Dim Instring As String 'this is not needed for now
Dim i As Integer
Dim cOut As Long

' Use COM1.
frmComm.MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
frmComm.MSComm1.Settings = &quot;9600,N,8,1&quot;
' Tell the control to read entire buffer when Input is used.
frmComm.MSComm1.InputLen = 0
' Open the port.
frmComm.MSComm1.PortOpen = True

'now spool out the string data
i = 1
While InStr(i, theString, &quot;&&quot;)
cOut = Val(Mid(theString, i, 4))
frmComm.MSComm1.Output = Chr(cOut)
i = i + 4
Wend

frmComm.MSComm1.PortOpen = False

End Sub
'===================


It should run on any windows platform but the target machine must have the MSCOMM control installed and registered for the program to work.

I'll gladly email you the source and compiled code or I could post it on my web site. Let me know.

 
From MSDOS prompt use the
MODE command to set the COM parameters
Use the echo command to send the sequence of characters.
Once you've dialed it in then save the commands to a batch file and execute it whenever you want it to send.
 
Status
Not open for further replies.
Back
Top