Jump to content

Looking for help on reading COM ports


 Share

Recommended Posts

I'm making a mecury switch that I am wiring to a 9-pin D-Sub and will write a script in AutoIT to test for open/closed circuit.

Original idea thread here: http://www.autoitscript.com/forum/index.php?showtopic=31145

I searched the forums but found nothing that I needed.

Anybody know of a thread or any other information that will aid me in reading the com port?

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

I'm making a mecury switch that I am wiring to a 9-pin D-Sub and will write a script in AutoIT to test for open/closed circuit.

Original idea thread here: http://www.autoitscript.com/forum/index.php?showtopic=31145

I searched the forums but found nothing that I needed.

Anybody know of a thread or any other information that will aid me in reading the com port?

TIA

One method is using the (licensed) MSComm COM library or the freely available NetComm COM library to access the port(s). See the Phone Dialer example for some code and download pointer to get you started.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Kewl beans...I found the link and d/l'ed the NetComm app.

I know this may be the wrong site to post the following question but I ask anyway:

I'm not an engineer but I'm trying to be :P

All I envision doing is wiring pins 2 and 3 to the leads on the mercury switch. I'm hoping all I'll need to do is send a signal and test to see that it comes in.

Does this seem correct or am I completely off base?

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Cool. What will you use it for?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Oh my Gawd...the shiet worked!

Thanks for the tip and code for NetComm.

Freaking sweet!

In all: Total cost: $5 Total time: 2 hours from idea to product!

Hell yes

Great, and yes I'd like to know what application this will be used in?

"In all: Total cost: $5 Total time: 2 hours from idea to product!" does that mean you work for $2.50 per hour? :P:nuke:

Link to comment
Share on other sites

I've written a app launcher in AutoIT (I do everything in AutoIT nowadays) that I'll use to define the port to monitor and the apps to launch. It will then run as a SysTray app to trigger off the appropriate application based on the switch state. One for the open state, the other for the closed state. I'll mount the switch to the back of my flat panel monitor so when I swivel it (which I do alot) it will trigger the app launches.

I've also written simple one-liner exe's with AutoIT to do send() commands that will send the hot keys that my video card uses to toggle screen orientation.

Basically I've just automated the screen orientation feature on my video card.

I've attached some screenshots of what I have so far. I'm currently doing a write up on the whole thing.

Vim: $2.50 on good days. Most (if not all) of my work is open-source so I make all of my stuff donation-ware (not that I get very many donations) :P:nuke:

Here's a link to the help file I'm making for the s/w: http://www.shrum.net/code/mercmon/help

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Thanks!

I've finished with my photos and they are posted. Either use the links in the homepage or click here to see the whole photo album of the project:

http://www.shrum.net/cats.php?search=20060...&limit=null

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Um, I'll get a cut of the profits for my original idea you used, won't I?

Just kidding - send it to the AutoIT people for a great forum.

Have you thought about another variation for those that don't have a serial port - say between two pins on a printer port? The PORT.DLL subroutine floating around can be harnessed to read and write any I/O port.

[Edit: See http://www.autoitscript.com/forum/index.php?showtopic=10231 and http://www.autoitscript.com/forum/index.php?showtopic=26076 for mention of PORT.DLL

I'm surprised a simple PORT I/O hasn't been added as an internal function within AutoIT as it should be quite easy to code and the call would be quite simple as there are only two parameters: The port number and the data to read or write. Look in the help file at the power of the VISA functions that extend AutoIT to control the GPIB bus.[/edit]

Edited by Confuzzled
Link to comment
Share on other sites

I'm surprised a simple PORT I/O hasn't been added as an internal function within AutoIT as it should be quite easy to code and the call would be quite simple as there are only two parameters: The port number and the data to read or write.

There's more to it then that...port #, port settings (the whole '9600,N,8,1' thing), open, send, inbuffercount, read, close. This is just off the top of my head.

However, I was wondering about that too. I spent a good amount of time going through the help file and forums looking for some internal method to do this but gave up and asked for help here and found out about the NetComm.ocx. The ocx works fine though.

It sorta sucks that I have to tell people 'go download this file and install it for MercMon to work'...sorta sounds like a ploy to spread spyware or something. I'm gunna try to FileInstall() the thing myself after I figure out all the regkeys it writes. Shouldn't be too hard. Just need to check with the guy who wrote the ocx to make sure it's ok.

As for donations I get, I'd be glad to kick a portion over here...as long as I *get* donations (see earlier post; look for ' :P:nuke: ')

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

This is why you may find reading the status port of the UART directly, or using the parallel port may be more efficient as you don't have to worry about setting the serial port parameters. Rather than using pins 2 and 3 on the serial port, have you considered using one of the status pins, such as DCD, RTS, CTS, DTR etc?

I've asked for a more general port access addition to AutoIT. Refer http://www.autoitscript.com/forum/index.php?showtopic=31281

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...