evandude Posted May 19, 2006 Share Posted May 19, 2006 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 More sharing options...
nfwu Posted May 19, 2006 Share Posted May 19, 2006 There is a library in C++ that you could use, found at:http://www.codeproject.com/system/serial.asp#) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
evandude Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) 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 May 19, 2006 by evandude Link to comment Share on other sites More sharing options...
nfwu Posted May 20, 2006 Share Posted May 20, 2006 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") #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
hackernohat Posted May 20, 2006 Share Posted May 20, 2006 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") #) Hic, Think in Windows XP version you can't access direct into a com port.Only thourgh a drive device Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now