
Keymaker
Active Members-
Posts
20 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by Keymaker
-
Hello Martin, i don't know if you remember me, but we corresponded about your UDFs a few years ago. Since then i have used them reliably. One question though. Is there a way to test if a serial cable has been removed after a successful connection has been made? The _CommPortConnection() function does not test for this type of (dis)connection. For USB to serial cables, I've used the error codes returned by _CommSetPort() function to detect disconnection, but this does not work with the standard (on board) UART since a cable removal does not result in the COM port being disabled like with the USB to serial cables. Sending a string with a UART type does not result in an error that I can use for detection. EDIT: Removing a USB to Serial cable at the DEVICE end, does not result in the COM port disappearing from the computer's hardware configuration (in this way it mimic's the standard UART). Disconnecting it from the COMPUTER end WILL result in removal of the COM port from the computer's configuration. By the way I am still using version 2.1 Thanks in advance. Regards, Keymaker
- 680 replies
-
- serial port
- virtual port
-
(and 2 more)
Tagged with:
-
This worked for me (at least for my lone fixed drive), but I need a way to get the drive serial by specifying which drive, preferably by letter (i.e., C:\, F:\). Does anyone know how to do this? The code returned empty or null for my USB drives though.
-
Can someone show me (step by step) how to use this script? I have a program i would like to release as trialware and I think i could use this script. Thanks!
-
Ok, I still can't get this work with my application. My application requests info from the DDE server using the following .NET code: private void SendInfoRequest_Click(object sender, EventArgs e) { string Command = String.Empty; byte[] data = new byte[1024]; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); try { using (DdeClient Client = new DdeClient("Player", InfoTopic.Text)) { Client.TryConnect(); // Connect to the server. if (Client.IsConnected) Messages.Text = "Connected successfully!" + "\r\n"; Command = InfoCommand.Text; if (Command != String.Empty) { Client.TryRequest(Command, 1, 5000, out data); Messages.Text = enc.GetString(data); } else Messages.Text = "No command to send. Please enter a valid command."; } } catch (Exception ex) { Messages.Text = ex.ToString(); } } As you can see, the Client.TryRequest() expects data to be returned in a byte array. When I execute this using the OnDDE_Request code provided above I get an error saying the byte array is null. It looks like the OnDDE_Request function returns a handle instead of byte data. I know my code works because I have tried it on two other DDE server apps and they return data in the correct format (byte data). What changes need to be made to the OnDDE_Request function so that it returns data as a byte array? Thanks Keymaker.
-
Thanks i'll try that. One last question. Why is it when I run Syntax check, I get errors saying: "@Unicode is an undefined macro" ? Thanks
-
A humble bump (or desperate cry for help!)... Thanks Keymaker
-
Hello Jos, Yes, I did. It has the ubiquitous #32770 as the class label. However, the controls in the window are relatively unique, so if if there was way to enumerate the controls of a window, I could check all the windows of class #32770 and see which one had a certain control. That may be another option and any suggestions on how to acomplish that are welcome. Thanks Keymaker
-
I am writing a "wrapper" program for an audio player using AutoIT. I need the window handle so I can manipulate the windows controls. Unfortunately, the player's window title changes depending on which song or track is playing so I can't reliably use that to get the window handle. The Process name does not change though. Is there a way I can get the window handle if I know the process name? Thanks Keymaker
-
Hello, I am using AutoIT3 to write a small DDE server program and used the Sample Server script found in this UDF: DDEML UDF My client program is a .NET app (which I've written using C# using NDde.dll). I've gotten the AutoIT UDF server program to accept client.Execute() commands from my client, but I need to know how to configure the server to send data back to the client in response to a client.Request() command. The structure of the NDde client.Request command is: client.Request (string Command, int Timeout). That command should return data (from the server) in CF_TEXT format. Alternatively, NDde has a client.TryRequest() command I could use with the structure: client.TryRequest( String item, Int32 format, Int32 timeout, out Byte[]& data) where: item = An item name supported by the current conversation. format = The format of the data to return timeout = The amount of time in milliseconds to wait for a response data = Data returned by server application I can use either one of these commands, depending upon which one is supported by the AutoIT DDEML UDFs. Thanks in advance. Keymaker
-
Hello, I am writing a DDE server in AutoIT3 using a slightly modified version of the sample Server program provided by this UDF. I will be communicating with it using a client program written in C# .NET using the NDde.dll class libraries and it's DDE functions. To request information from the server, I will be using the NDde command: client.Request (string Command, int Timeout) to request data from the AutoIT3 based server. Will this work with the sample server program? In other words, can anyone give me an example of what I need to add to the (sample)server script to have it return data when it receives a client.Request() command from a client program? Thanks! Keymaker
-
@rasim, This little script did the trick for me and reliably removed my left over icons. Thanks!
-
Hello All, I have written a custom shutdown script for my media server which reliably shuts the server down after a pre-determined time of inactivity (no mouse moves or keystrokes). However, I don't want the server to shut down while I am streaming content from it to a remote computer. I would like to use the network utilization value (as found in task manager) as an additional parameter for shut down (i.e., if the network utilization > 5%, keep computer on). Is there a way to read this network utilization % via AutoIt script? I've searcehd the forum and could not find any info on getting the Network Utilization %. Thanks in advance!
-
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
Yes, I think 4 channels would be enough... Thanks again. -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
Martin, I finally found and fixed my hardware problem and properly tested the _CommSwitch() function and it WORKS! It would be nice if you can add the ability to use more than 2 serial ports though. In the meantime, I can get by with two ports. I sincerely thank you for all your efforts to help me resolve my problem. Thanks again. Regards, Keymaker -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
Martin, I have not had a chance to test the new _CommSwitch function yet. I appear to be having a hardware issue with my COM2 port. I'll report back after I've resolved the problem. Regards, Keymaker -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
It works! No flow control ( Flow control = 2) fixed the problem. Perhaps my DirecTV satellite application is the only one (so far) that needs a strict adherence to NO flow control. Also, the files you sent me seem to work. I have NOT yet tried the new switch function. I will try it later. Do I implement the switch() function as follows? and is the function name preceded by an underscore (_)?: _CommSetPort($COM1, $sErr, 9600, 8, 0, 1, 2) ; Set up COM1 for DirecTV STB _CommSetPort($COM2, $sErr, 9600, 8, 0, 1, 2) ; Set up COM2 for Krell Preamp Switch($COM2) _CommSendByte($data) ; Write to COM1 Switch($COM1) _CommReadChar() ; Read from COM2 Regards, Keymaker -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
Thanks for the prompt solution martin. Regards, Keyamker -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
That would help greatly! By the way, I've tried what you suggested in the previous post, but still no luck. The read functions all return "0" or "": The script hangs at that point because it never reads any data that is not "0" or "". My previous method using $MsComm object reliably read the input and gave the correct data. Maybe there is something I'm missing. Also, your flow control choices are hardware or Xon/Xoff, but no choice for "None". Thanks again for your efforts.. Keymaker. -
Chr(0) and rs232 communication
Keymaker replied to Keymaker's topic in AutoIt General Help and Support
Thanks for the reply Martin. I tried to use your dll and UDfFs earlier. The send function (_CommSendByte() ) works and solves my Chr(0) problem. However, I have two problems with your UDF's and DLL: 1. My application will need to use two serial ports (COM1 controls the preamp, COM3 communicates withe the STB). Your UDFs make no provision for using more than one serial port. Whereas with the MScomm object, I can declare as many COMs as I need and address each one individually for reading and writing, e.g., $MsComm1.Ouput to write to COM1 and $MsComm2.Input to read from COM2. Your read and write UDFs are only applicable to the current open serial port declared in the _CommsetPort() function. 2. I can't seem to read any data FROM the Set Top Box using any of your read functions (_CommReadByte(), _CommReadChar(), _CommgetString() ). See my code below using your functions to help me determine what is wrong. Regards, Keymaker #include <Constants.au3> #include <CommMG.au3> #include <string.au3> #include <Misc.au3> #include <array.au3> ;----------------------------------------------; ; Make tray item ;----------------------------------------------; Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetClick(16) TraySetIcon(@ScriptDir & "\Images\Transmitting.ico") $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($Exit,"ExitEvent") Local $COM1 = 1, $COM3 = 242, $SuccessFlag, $response, $sErr Const $CMD_TIMEOUT = 500 ; 500 milliseconds Dim $command[6] $command[0] = 0xFA ; "0xFA" = Command prefix $command[1] = 0xA5 ; "0xA5" = user command $command[2] = 0x00 ; "0x00" = switch toggle $command[3] = 0x01 ; "0x01" = remote button $command[4] = 0xF7 ; "0xF7 = menu command $command[5] = 0x0D ; "0D" = @CR ;----------------------------------------------; ; Setup Serial Port(s) ;----------------------------------------------; _CommSetPort($COM1, $sErr, 9600, 8, 0, 1, 0) ;----------------------------------------------; ; Send MENU command ;----------------------------------------------; MsgBox(0, "TEST", "Click OK to send MENU command ") $i = -1 Do $i = $i + 1 _CommSendByte($command[$i]) Until $command[$i] = 0x0D ;@CR Do Sleep(5) Until _CommGetInputcount() <> " " ; Data available? $response = _CommReadChar() MsgBox(0, "OK", "Final return value was : " & $response) Exit ;----------------------------------------------; ; Tray function ;----------------------------------------------; Func ExitEvent() Exit EndFunc -
Hello forum, Below is a script I have been writing to control a DirecTV satellite receiver Set Top Box (STB). The STB requires a sequence of Hex bytes be sent to it via rs232 serial. I am using the MScomm object to communicate with the STB. The problem is the Chr(0) data character. I can send any other data byte fine and the STB responds accordingly. But for some reason Chr(0) does not transmit properly. I do not think it is the MScomm object, as I have tried NetCommX with the same results. Has anyone found a workaround for this problem yet? I have scoured the AutoIT forums and found a couple of links where others have reported the same issue: http://www.autoitscript.com/forum/index.ph...0&hl=chr(0). Unfortunately they did not have have any solutions. The relevant part of my code is included in this post. In the data array below, the "0x00" byte is not recognized by the STB but all other data bytes are. Also I can send 0x00" using 3rd party serial programs and the STB responds. SO I think it is some quirk with AutoIT. Regards. #include <Constants.au3> #include <string.au3> #include <Misc.au3> #include <array.au3> ;----------------------------------------------; ; Make tray item ;----------------------------------------------; Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetClick(16) TraySetIcon(@ScriptDir & "\Images\Transmitting.ico") $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($Exit,"ExitEvent") ;----------------------------------------------; ; Setup Serial Port(s) ;----------------------------------------------; Local $COM1 = 1 $MsComm1 = ObjCreate("MSCOMMLib.MsComm") ;$MsComm1 = ObjCreate("NETCommOCX.NETComm") With $MsComm1 .CommPort = $COM1 ; Set COM1 port for ... .Settings = "9600,N,8,1"; 9600 Baud, 8 bits, 1 stop, No parity .InputMode = 0 ; 0 = TEXT MODE, 1 = BINARY MODE .Handshaking = 0 .InBufferSize = 512 .InputLen = 1 .PortOpen = 1 .NullDiscard = 0 EndWith Dim $satCMD[8] ;--------------------------------------------------------- ; TEST program stars here ;--------------------------------------------------------- $satCMD[0] = 7 ; Ch244 $satCMD[1] = "0xFA" $satCMD[2] = "0xA6" $satCMD[3] = "0x00" $satCMD[4] = "0xF4" $satCMD[5] = "0xFF" $satCMD[6] = "0xFF" $satCMD[7] = "0x0D" ;SendSatCommand($satCMD) MsgBox(0, "OK", "Response from STB was : " & SendSatCommand($satCMD), 3) Exit ;----------------------------------------------; ; Satellite receiver command function ;----------------------------------------------; Func SendSatCommand($CommandArray) Local $SUCCESS = 244, $COMMAND_OK = 240, $PARAMETERS_OK = 242 Local $response Const $CMD_TIMEOUT = 500; 500 milliseconds $i = 0 Do $i = $i + 1 SatSend($CommandArray[$i]) ;MsgBox(0, "", "Command is : " & $CommandArray[$i], 2) Until $CommandArray[$i] = "0x0D" ;@CR ; Wait for response 0xF0 = 240 = command acknowledged $time = TimerInit() Do Sleep(5) Until $MsComm1.InBufferCount Or TimerDiff($time) > $CMD_TIMEOUT $response = SatReceive() If $response <> $COMMAND_OK Then Return "Error 1 " & $response ; Wait for response 0xF2 or 0xF4 = parameters received $time = TimerInit() Do Sleep(5) Until $MsComm1.InBufferCount Or TimerDiff($time) > $CMD_TIMEOUT $response = SatReceive() If $response = $SUCCESS Then Return "Success!" If $response <> $PARAMETERS_OK Then Return "Error 2 " & $response ; Wait for the 0xF4 response, "command successful". $time = TimerInit() Do Sleep(5) Until $MsComm1.InBufferCount Or TimerDiff($time) > $CMD_TIMEOUT $response = SatReceive() If $response = $SUCCESS Or $response = 0 Then Return "Success!" Return "Error 3 " & $response EndFunc ;----------------------------------------------; ; Tray function ;----------------------------------------------; Func ExitEvent() Exit EndFunc ;------------------------------------------------------; ; Serial data ouput function to Satellite receiver ;------------------------------------------------------; Func SatSend($data) With $MsComm1 .OutBufferCount = 0 .InBufferCount = 0 If .PortOpen = True Then .Output = Chr($data) EndIf EndWith EndFunc ;-----------------------------------------------------; ; Serial data input function from Satellite receiver ;-----------------------------------------------------; Func SatReceive() $DataIn = "" With $MsComm1 If .PortOpen = False Then .PortOpen = True EndIf If .InBufferCount Then $DataIn = .Input ;Data EndIf EndWith Return Asc($DataIn) EndFunc