Jump to content

Chr(#) to COM8 ?


Recommended Posts

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 open

If .PortOpen = False Then .PortOpen = True

'send the data

.Output = Chr$(255)

.Output = Chr$(1)

.Output = Chr$(0)

End With 'MSComm1

End Sub

Private Sub cmdOn_Click()

With MSComm8

'make sure the serial port is open

If .PortOpen = False Then .PortOpen = True

'send the data

.Output = Chr$(255)

.Output = Chr$(1)

.Output = Chr$(1)

End With 'MSComm1

End Sub

Link to comment
Share on other sites

Yes, you can easily deal with what you have shown using my udf. There's a link in my signature.

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

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

yes

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

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

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