635 posts in this topic
I can easily find my modem comport number using the code below:-
#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> Global $key = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM","\Device\ssudmdm0000") Local $iError = 0 If @error Then ; The server is probably offline/port is not opened on the server. $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError) Else MsgBox($MB_ SYSTEMMODAL, "MODEM:", $key) EndIf
but the thing is I am planning to design a small tool by which it can read the modem COM port and set the COM number and send AT command to modem port using UDF CommMG.au3 created by Martin. I added some below code to martins file :-
;====================================================================================================================== ;CommSendStandard,a new function for sending information to a serial port. ;====================================================================================================================== Func _CommSendStandard($port,$error,$command) _CommSetPort($port,$error,9600,8,0,1,2) if $error <> '' Then MsgBox(262144,'Port Error = ',$error) EndIf _CommSendString($command & @CR) EndFunc ;==>_CommGetLineStates ;=============================================================================================== After adding I wrote the below code for sending AT command to modem port but its not working.
Please check the below code and let me know for the issue.
;===================================================================================== #include "C:\Program Files (x86)\AutoIt3\SciTE\CommMG.au3" #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> Global $key = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM","\Device\ssudmdm0000") Local $iError = 0 If @error Then ; The server is probably offline/port is not opened on the server. $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError) Else MsgBox($MB_SYSTEMMODAL, "MODEM:", $key) EndIf Local $port=$key Local $porterror _CommSendStandard($port,$portError,"AT+CFUN=1,1") ;================================================================================================ but If I set the port number by my own in the code (for eg :- port number 8 or any value instead of $key) it works fine and the modem gets reset.I want to know if there is any way to get the port number to a variable $port and discarding so that my above code works fine...In that case user donot have to take care of entering the port manually everytime and the script will automatically read the port number and set itself.
I have several different devices connected to my desktop PC with USB COM adapters.
Sometimes there is some error that will cut my USB COM device communication (usualy caused by lose USB connector)... After reconnecting that USB COM adapter, by some reason, Windows will give it different COM port number.
I know there are some devices with integrated COM port circuit and they are used by client programs that can found them and only them by some USB hardware relate details and then use their COM port to communicate with correct COM device.
It would be better to define some known and static hardware related string from device managers USB COM adapter details to my script config file, than always redefine different COM port to it.
How can I do this trick with autoit?
I communicate COM devices with cfxUDF.au3 AutoIt UDF.
I have written an AutoIt program that communicates with a RFXCOM transciever to control my home. This program runs 24/7 and occasionally I get the following message in a modal window:
Line 6102 (File "C:\homecontrol\HC.exe"):
Error: Missing right bracket ')' in expression.
My program waits for an operator input. So I have lost control and I am not able to terminate the program and start it again. Since my program has only a few hundred lines the error must be in one of the libraries. My questions are:
What is causing this error?
How can I trap this error?
In which library is this error generated?
This are my includes:
In the code I have already an error trap:
$objErr = ObjEvent("AutoIt.Error","MyErrFunc")