jaberwacky Posted February 15 Share Posted February 15 (edited) Hello! I have used the helpfile, the posts of excellent coders on this forum, and ChatGPT to cobble together (copy and pasted essentially) a script that will enable remote control of an Onkyo or Integra audio video receiver over the network! I'm just so excited that I had to post what I have put together so far! Please tell me if this could be useful to you. Also, please do tell me if I'm going about this all wrong! I'll take any and all comments, suggestions, etc. expandcollapse popup; By myself, I am not a good programmer. It's with the help of people such as ; SoulA that I can even dress myself in the morning! ; Credit to ChatGPT too! ; https://www.autoitscript.com/forum/topic/84095-receiving-data-from-a-connected-tcp-device/ ; PsaltyDS is the penguin! ; Please send much love!: https://www.autoitscript.com/forum/profile/9334-psaltyds/ ; https://www.autoitscript.com/forum/topic/117300-help-please-with-tcpip-script-to-control-onkyo-receiver/ #include-once #include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIError.au3> Global Const $sIPAddress = "192.168.0.209" Global Const $iPort = 60128 TCPStartup() tcp_receive() TCPShutdown() Func tcp_receive() Do $socket = TCPConnect($sIPAddress, $iPort) Until $socket <> -1 sleep(100) _TCPSend($socket, "PWRQSTN") $Recv = _TCPRecv($Socket) $Recv = Model_ExtractCommand($Recv) ConsoleWrite($Recv & @CRLF) EndFunc Func _TCPSend($socket, $cmd) Local Const $ConnectedSocket = TCPConnect($sIPAddress, $iPort) Local Const $binISCP_Header = StringToBinary("ISCP") Local Const $binISCP_HeaderSize = Binary("0x00000010") ; Header size = 16 Local Const $binISCP_DataSize = Binary("0x00000007") ; Data size (command length) = 7 chars Local Const $binISCP_Version = Binary("0x01000000") ; Version 1.0.0.0 Local Const $binISCP_Data = StringToBinary("!1" & $cmd) ; Command = !1PWR01 Local Const $binISCP_End = Binary("0x0D") ; @CR Local Const $binISCP_Message = $binISCP_Header & _ $binISCP_HeaderSize & _ $binISCP_DataSize & _ $binISCP_Version & _ $binISCP_Data & _ $binISCP_End ; Send message over connected socket TCPSend($ConnectedSocket, $binISCP_Message) EndFunc Func _TCPRecv($socket) Local $timeout = TimerInit() Local $Recv Do $Recv = TCPRecv($socket, 2048) If TimerDiff($timeout) > 1000 Then ConsoleWrite("Timeout" & @CRLF) Exit EndIf Until $Recv <> "" Return $Recv EndFunc ; ChatGPT! Func Model_ExtractCommand($data) $data = BinaryMid($data, 3) ; chop off the 0x ; Extract the data portion from the binary string Local $dataBinary = BinaryMid($data, 17, 5) ; Convert the binary data to a string Return BinaryToString($dataBinary) EndFunc Edited February 15 by jaberwacky Forgot to credit PsaltyDS! argumentum 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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