I need to write a batch file that can send data over a serial comm port. It needs to be compatible with Windows XP and 7.
How can I send a line like "A, B, C, D, E, F" over Comm 1 at 4800kbs, 8 data bits, Even Parity, and 1 Stop Bit. Any ideas? Thanks.
9 replies to this topic
#1
Posted 23 October 2010 - 06:34 PM
|
|
|
#2
Posted 26 October 2010 - 05:46 PM
#3
Posted 26 October 2010 - 11:42 PM
i read that long before i found this forum. I followed the tutorials for it and played with it for a while but couldnt get it to work, figured there must be a different way i could try.
also if your read that link youll see it was another guy asking the same question and getting no answers.
also if your read that link youll see it was another guy asking the same question and getting no answers.
#4
Posted 27 October 2010 - 08:15 AM
#5
Posted 28 October 2010 - 12:55 PM
Well Id like to find a batch solution because there are a handful of commands that need to be used fairly often for troubleshooting the systems im working on. If I could figure this out life would be soooo much easier.
#6
Posted 30 October 2010 - 01:11 AM
Hello All,
Actually serial ports are treated as files with names of "COMxx" (without quotes and xx indicates serial port index). Anything you send/write to that file name will be sent to the corresponding serial port. For example, to send "ABCD" to serial port 1 (COM1), you only need to add the following line to your batch file:
The following will send content of MyFile.txt to serial port 1.
To configure the communication settings, you can use MODE command. In your case, before send anything to COM1, I would add the following line to the batch file:
And like most dos commands, to get complete details of that MODE can do all you need to do is run "mode /?" in command prompt. :)
Cheers!
Actually serial ports are treated as files with names of "COMxx" (without quotes and xx indicates serial port index). Anything you send/write to that file name will be sent to the corresponding serial port. For example, to send "ABCD" to serial port 1 (COM1), you only need to add the following line to your batch file:
ECHO ABCD > COM1
The following will send content of MyFile.txt to serial port 1.
COPY C:\Tmp\MyFile.txt COM1
To configure the communication settings, you can use MODE command. In your case, before send anything to COM1, I would add the following line to the batch file:
MODE COM1:4800,e,8,1
And like most dos commands, to get complete details of that MODE can do all you need to do is run "mode /?" in command prompt. :)
Cheers!
Edited by LuthfiHakim, 30 October 2010 - 02:59 AM.
Correcting grammar mistake and add a word to clarify things
#7
Posted 30 October 2010 - 02:37 AM
Ahh this is awesome, im going to work on this today.
Edit:
Okay question, I have a cable that I use to talk to my terminals at work, its just a simple two wire cable, one end is black (connects to the transmitter) and the other is grey (connected to the receiver). For example if I have a terminal that I want to dump some diag info I will connect the black connector to the RS232 port on the terminal and the grey one to my laptop. This connectors are generic, but my question is when I try to use a pair of old red null modems it wont work. The idea being I could use teh null modems for two way communication, but when I connect my grey and black cable my batch file I wrote with your code works fine. I have always thought that on two RS232 ports if I put two null modems and a rs232 cable I could have two way communication, but I cant seem to get one way to work, any ideas? Thanks.
Edit:
Okay question, I have a cable that I use to talk to my terminals at work, its just a simple two wire cable, one end is black (connects to the transmitter) and the other is grey (connected to the receiver). For example if I have a terminal that I want to dump some diag info I will connect the black connector to the RS232 port on the terminal and the grey one to my laptop. This connectors are generic, but my question is when I try to use a pair of old red null modems it wont work. The idea being I could use teh null modems for two way communication, but when I connect my grey and black cable my batch file I wrote with your code works fine. I have always thought that on two RS232 ports if I put two null modems and a rs232 cable I could have two way communication, but I cant seem to get one way to work, any ideas? Thanks.
Edited by dargueta, 30 October 2010 - 09:07 AM.
Double post
#8
Posted 30 October 2010 - 04:46 AM
There are two possibilities I can think of (beside the old red cables was damaged, lol):
Actually each RS232 port is capable of full duplex communication. So both ends can send and receive data at the same time, no need to use two ports to get two ways communication. However the practical implementation is still depend on the communicating devices. Well, full duplex capability of RS232 port means nothing if one of them only capable of one way communication.
- Your old red null modem actually is cross over cable, i.e. designed for DTE-DCE communication instead for DTE-DTE in your case.
- Your old red null modems use custom hardware handshaking.
Quote
I have always thought that on two RS232 ports if I put two null modems and a rs232 cable I could have two way communication
#9
Posted 30 October 2010 - 10:37 AM
Oh yea I meant two ports as in port a on device a and port b on device b.
I use these null modems daily to do RS232 communication, I know my cabling is good and right now I am just testing between two laptops. when I use my grey and black cable I get one way comm between the two laptops, but with my null modems i dont get anything. But I have to use teh null modems to load software updates to the terminals so I know that they are good. Hmm, maybe I should try my blue Cisco Console Cable.
I use these null modems daily to do RS232 communication, I know my cabling is good and right now I am just testing between two laptops. when I use my grey and black cable I get one way comm between the two laptops, but with my null modems i dont get anything. But I have to use teh null modems to load software updates to the terminals so I know that they are good. Hmm, maybe I should try my blue Cisco Console Cable.
#10
Posted 04 November 2010 - 02:58 AM
Your best bet to answer the problem is finding out the connections between the pins.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









