LarsBNygaard Posted April 10, 2012 Share Posted April 10, 2012 How do I set a script to send i.e. Chr(255) + Chr(1) + Chr(0) to the COM8 port?I need this, in order to turn a relay connected to CON8 on/off.Any help will be appreciated!----------------------------------------------------------------------Sample VB6 code :Private Sub cmdOff_Click()With MSComm8'make sure the serial port is openIf .PortOpen = False Then .PortOpen = True'send the data.Output = Chr$(255).Output = Chr$(1).Output = Chr$(0)End With 'MSComm1End SubPrivate Sub cmdOn_Click()With MSComm8'make sure the serial port is openIf .PortOpen = False Then .PortOpen = True'send the data.Output = Chr$(255).Output = Chr$(1).Output = Chr$(1)End With 'MSComm1End Sub Link to comment Share on other sites More sharing options...
JohnOne Posted April 10, 2012 Share Posted April 10, 2012 martin has a great com.dll UDF in example scripts forum which will more than likely help you. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
martin Posted April 10, 2012 Share Posted April 10, 2012 Yes, you can easily deal with what you have shown using my udf. There's a link in my signature. LarsBNygaard 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LarsBNygaard Posted April 12, 2012 Author Share Posted April 12, 2012 Thanks a zillion to John and Martin, I've downloaded and looked at the example script, and I must say, that here I'm overchallenged... Would it be possible to talk one of you into writing two sniplets of code for me, one "turn it on" sending Chr(255) + Chr(1) + Chr(1) to COM8 and one "turn it off", sending Chr(255) + Chr(1) + Chr(0) to COM8 in such a manner, that I can set the trigger myself, i.e. #include <Date.au3> $Dato=( _NowDate()) -and then set the date as trigger, for sending the chr¤'s to COM8..? Link to comment Share on other sites More sharing options...
martin Posted April 12, 2012 Share Posted April 12, 2012 yes LarsBNygaard 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
LarsBNygaard Posted April 14, 2012 Author Share Posted April 14, 2012 Thanks a zillion, I'll wait in great excitement to see the solution.! Link to comment Share on other sites More sharing options...
martin Posted April 16, 2012 Share Posted April 16, 2012 You have misunderstood "yes". Your question was "Would it be possible to talk one of you into writing two......" So "yes" it would be possible, but the chances of succeeding in pursuading me at least are very, very slim. If you put in some effort and make an attempt at some code then I am happy to help with any problems. But using someone else to think for you is a bad idea IMO. Using someone else so that you can do nothing is just bloody lazy. There is an example script with the udf, and the udf contain information on all the functions. Then if you look through the thread for the udf you will find examples where people have used the udf to send characters as you want to do. So get your ass into gear. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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