Jump to content

Simple Serial Port Stuff


Recommended Posts

What would be the best way to access the serial port from a script? All I really need to do is have it send a single character, or something equally simple, most likely no need for bidirectional communication although that might be nice in the future.

Looking over the commands available, it seems that I could do it by making a small EXE in my programming language of choice that sends what I need when run, and use the Run() command in autoit to execute it when desired. And it looks like I could also make a DLL that has a function that does this transmission for me, and then access that from within autoit. Am I missing any others?

So... what do you think would be the best way? I'm new to autoit, I'm working off an existing, semi-working script that I'm trying to improve, so I appreciate the help.

Link to comment
Share on other sites

Thanks. I'm planning to use C# for whatever serial stuff I have to do, as I've toyed with it a bit in the past and I know I can get it working (eventually), my main problem is the interaction between that chunk of code, and autoit.

Now that I just saw autoitX, and realized I can run autoit commands from within C#, I'm torn on whether I should use autoit or C# for the bulk of the functionality... ie - I could make a C# program that handles the serial and uses autoit commands to handle all the color searching/interaction with the window that I need, or use an autoit script that calls a DLL made in C# to handle the serial stuff...

Since I already have the entire autoit script that pretty much works, it seems probably wiser for me to start off with the latter, and try making and interacting with a DLL for the serial stuff. When I started, I was kind of hoping that autoit would have had built in serial port functionality, but based on the uses I've seen I can't see it being very important to the average user, and it would have been just too easy for me :)

Edited by evandude
Link to comment
Share on other sites

Also, you could try this:

#include <Process.au3>

Func PrintToSerial($PortName, $Data)
   _RunDOS("echo "&$Data&" > "&$PortName)
EndFunc

(I've only tested on a virtual serial USB printer port "LPT1")

#)

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...