Jump to content



Photo

Chr(#) to COM8 ?


  • Please log in to reply
6 replies to this topic

#1 LarsBNygaard

LarsBNygaard

    Seeker

  • Active Members
  • 17 posts

Posted 10 April 2012 - 01:12 PM

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







#2 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,955 posts

Posted 10 April 2012 - 01:25 PM

martin has a great com.dll UDF in example scripts forum which will more than likely help you.

#3 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,202 posts

Posted 10 April 2012 - 10:23 PM

Yes, you can easily deal with what you have shown using my udf. There's a link in my signature.
  • LarsBNygaard likes this
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.

#4 LarsBNygaard

LarsBNygaard

    Seeker

  • Active Members
  • 17 posts

Posted 12 April 2012 - 08:11 AM

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

#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,202 posts

Posted 12 April 2012 - 10:01 PM

yes
  • LarsBNygaard likes this
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.

#6 LarsBNygaard

LarsBNygaard

    Seeker

  • Active Members
  • 17 posts

Posted 14 April 2012 - 08:28 AM

Thanks a zillion, I'll wait in great excitement to see the solution.!

#7 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,202 posts

Posted 16 April 2012 - 06:48 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users