Jump to content

cheeroke

Active Members
  • Posts

    23
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

cheeroke's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. Hi I am not sure how to call it properly, but for those of you who use SciTE, when you typing built in function and about to pass parameters to it you can see popup with all the ones which can be passed. Question: how to create something like that for my own functions? Thanks
  2. Ok, I know it is a bit old, but i had same problem and found how to do it without over coding so there is my solution for the printing variable value and name, hope someone will find it useful. Func VariableChecker($VariableName, $VariableValue) SplashTextOn("Variable Checker", @CRLF &@CRLF & "Status of " & @CRLF &@CRLF & $VariableName & " is: " & $VariableValue , 300,200) Sleep(5000) SplashOff() EndFunc now just call it like so: VariableChecker("$MyVariableToBeChecked", $MyVariableToBeChecked)
  3. Solution for above is here:
  4. ok, i managed it to work. Removing Local $CmBoBaudOptic = 19200 ; Baud Local $CmBoBaudScanner = 115200 ; Baud from top of the script and placing it within desired functions SendData2() and SendDataOPTICS() like below: Func SendDataOPTIC($FileName, $LineNumber) $CmBoBaudOptic = 19200 ; Baud ;Start up communication _CommSwitch($CMPortOptic) (...) and Func SendData2($FileName, $LineNumber) $CmBoBaudScanner = 115200 ; Baud ;Start up communication _CommSwitch($CMPortScanner) (...)
  5. Hi, Does anyone have an idea how to controll two COM ports? I've changed @Brian39 above code for sending strings but I need to controll two different COM ports with different Baud rate. AS long as I have connection with both COM's second one does not "respect" different Baud rate. My code below: #include "FilesHandling.au3" ;Include the Serial UDF #include 'CommMG.au3' ;Internal for the Serial UDF Global $sportSetError = '' ;COM Vars ;_CommSetPort($iPort, ByRef $sErr, $iBaud = 9600, $iBits = 8, $iPar = 0, $iStop = 1, $iFlow = 0, $RTSMode = 0, $DTRMode = 0) Global $CMPortScanner = 7 ; Port Global $CMPortOptic = 10 ; Port Local $CmBoBaudOptic = 19200 ; Baud Local $CmBoBaudScanner = 115200 ; Baud Global $CmboDataBits = 8 ; Data Bits Global $CmBoParity = "none" ; Parity Global $CmBoStop = 1 ; Stop Global $setflow = 2 ; Flow Global $RTSMode = 1 Global $DTRMode = 1 Global $iWait = 0 ;==========================Funcions============================= ;DailyQC Func SerialPort_UsingCommMG_DailyQC($FileName1, $LineNumber1) SendData2($FileName1, $LineNumber1) Sleep(500) EndFunc ;Single Test Func SerialPort_UsingCommMG_SingleTest($FileName1, $LineNumber1, $FileName2, $LineNumber2) SendData2($FileName1, $LineNumber1) Sleep(500) SendData2($FileName2, $LineNumber2) Sleep(500) EndFunc ; BatchMode Func SerialPort_UsingCommMG_BatchMode($NumberOfTests, $FileName1, $FileName2) For $i = 1 To $NumberOfTests SendData2($FileName1, $i) Sleep(500) SendData2($FileName2, $i) Sleep(500) Next EndFunc Func SerialPort_UsingCommMG_OpticSend($Event) Sleep(500) Switch($Event) Case 1 ;"AK" SendDataOPTIC("OpticsData.txt",1) Case 2 ;"SHUT" SendDataOPTIC("OpticsData.txt",2) Case 3 ;"OPEN" SendDataOPTIC("OpticsData.txt",3) Case 4 ;"Data" SendDataOPTIC("OpticsData.txt",4) Case 5 ;"SData" SendDataOPTIC("OpticsData.txt",5) EndSwitch EndFunc ;~ ;Func SerialPort_UsingCommMG_ ;~ ;for testing only Func SerialPort_Test_SHUT() SendDataOPTIC("OpticData.txt", 1) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 2) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 3) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 4) SendDataOPTIC("OpticData.txt", 6) Sleep(100) EndFunc ;==========================EOF Funcions=================================== Func SendData2($FileName, $LineNumber) ;Start up communication _CommSwitch($CMPortScanner) _CommSetPort($CMPortScanner, $sportSetError, $CmBoBaudScanner, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $RTSMode, $DTRMode) $sStrData = ReadFile($FileName, $LineNumber) $iNumString = StringLen($sStrData) $tStrData = DllStructCreate("String["&$iNumString&"]") $iRet = _CommSendString($sStrData,1) If @error Or $iRet = -1 Then ConsoleWrite("!Error: " & @error & @CRLF) _CommClearOutputBuffer() _CommClearInputBuffer() _Commcloseport() EndFunc Func SendDataOPTIC($FileName, $LineNumber) ;Start up communication _CommSwitch($CMPortOptic) _CommSetPort($CMPortOptic, $sportSetError, $CmBoBaudOptic, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $RTSMode, $DTRMode) $sStrData = ReadFile($FileName, $LineNumber) $iNumString = StringLen($sStrData) $tStrData = DllStructCreate("String["&$iNumString&"]") $iRet = _CommSendString($sStrData,1) If @error Or $iRet = -1 Then ConsoleWrite("!Error: " & @error & @CRLF) _CommClearOutputBuffer() _CommClearInputBuffer() _Commcloseport() EndFunc
  6. Hi, I've changed @Brian39 code from this topic and change it to send whole string. I've tried to use same script to manage two COM ports with different Baud rate, but without any luck. Can anyone help me and show me what ned to be changed to manage more than one COM port with different Baud Rate using below script - if possible. Otherwise how to achieve this? Functions SendData2() & SendDataOPTIC() should use different Baud rate but apart of using different COM port it does not want to use different Baud rate, it picking up (whichever is first assigned) (...) Global $CMPortScanner = 7 ; Port Global $CMPortOptic = 10 ; Port Local $CmBoBaudOptic = 19200 ; Baud Local $CmBoBaudScanner = 115200 ; Baud (...) Please help. code below: #include "FilesHandling.au3" ;Include the Serial UDF #include 'CommMG.au3' ;Internal for the Serial UDF Global $sportSetError = '' ;COM Vars ;_CommSetPort($iPort, ByRef $sErr, $iBaud = 9600, $iBits = 8, $iPar = 0, $iStop = 1, $iFlow = 0, $RTSMode = 0, $DTRMode = 0) Global $CMPortScanner = 7 ; Port Global $CMPortOptic = 10 ; Port Local $CmBoBaudOptic = 19200 ; Baud Local $CmBoBaudScanner = 115200 ; Baud Global $CmboDataBits = 8 ; Data Bits Global $CmBoParity = "none" ; Parity Global $CmBoStop = 1 ; Stop Global $setflow = 2 ; Flow Global $RTSMode = 1 Global $DTRMode = 1 Global $iWait = 0 ;==========================Funcions============================= ;DailyQC Func SerialPort_UsingCommMG_DailyQC($FileName1, $LineNumber1) SendData2($FileName1, $LineNumber1) Sleep(500) EndFunc ;Single Test Func SerialPort_UsingCommMG_SingleTest($FileName1, $LineNumber1, $FileName2, $LineNumber2) SendData2($FileName1, $LineNumber1) Sleep(500) SendData2($FileName2, $LineNumber2) Sleep(500) EndFunc ; BatchMode Func SerialPort_UsingCommMG_BatchMode($NumberOfTests, $FileName1, $FileName2) For $i = 1 To $NumberOfTests SendData2($FileName1, $i) Sleep(500) SendData2($FileName2, $i) Sleep(500) Next EndFunc Func SerialPort_UsingCommMG_OpticSend($Event) Sleep(500) Switch($Event) Case 1 ;"AK" SendDataOPTIC("OpticsData.txt",1) Case 2 ;"SHUT" SendDataOPTIC("OpticsData.txt",2) Case 3 ;"OPEN" SendDataOPTIC("OpticsData.txt",3) Case 4 ;"Data" SendDataOPTIC("OpticsData.txt",4) Case 5 ;"SData" SendDataOPTIC("OpticsData.txt",5) EndSwitch EndFunc ;~ ;Func SerialPort_UsingCommMG_ ;~ ;for testing only Func SerialPort_Test_SHUT() SendDataOPTIC("OpticData.txt", 1) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 2) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 3) SendDataOPTIC("OpticData.txt", 6) Sleep(100) SendDataOPTIC("OpticData.txt", 4) SendDataOPTIC("OpticData.txt", 6) Sleep(100) EndFunc ;==========================EOF Funcions=================================== Func SendData2($FileName, $LineNumber) ;Start up communication _CommSwitch($CMPortScanner) _CommSetPort($CMPortScanner, $sportSetError, $CmBoBaudScanner, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $RTSMode, $DTRMode) $sStrData = ReadFile($FileName, $LineNumber) $iNumString = StringLen($sStrData) $tStrData = DllStructCreate("String["&$iNumString&"]") $iRet = _CommSendString($sStrData,1) If @error Or $iRet = -1 Then ConsoleWrite("!Error: " & @error & @CRLF) _CommClearOutputBuffer() _CommClearInputBuffer() _Commcloseport() EndFunc Func SendDataOPTIC($FileName, $LineNumber) ;Start up communication _CommSwitch($CMPortOptic) _CommSetPort($CMPortOptic, $sportSetError, $CmBoBaudOptic, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $RTSMode, $DTRMode) $sStrData = ReadFile($FileName, $LineNumber) $iNumString = StringLen($sStrData) $tStrData = DllStructCreate("String["&$iNumString&"]") $iRet = _CommSendString($sStrData,1) If @error Or $iRet = -1 Then ConsoleWrite("!Error: " & @error & @CRLF) _CommClearOutputBuffer() _CommClearInputBuffer() _Commcloseport() EndFunc
  7. Hi all, I got this code and would like to be able to change Baud Rate and instead of sending character by character i would like to be able (if possible) to send whole string. But i don't know how to change it. I am taking input from file and processing whole line (this is done in FilesHandling.au3). To execute this i am just calling SendData("FileName", int) in "main" script. Any help very appreciated. #include <WinAPI.au3> #include <Array.au3> #include "FilesHandling.au3" ;init DLL function, we need handle to call the function $h = DllCall("Kernel32.dll", "hwnd", "CreateFile", "str", "\\.\COM19", "int", BitOR($GENERIC_READ,$GENERIC_WRITE), "int", 0, "ptr", 0, "int", $OPEN_EXISTING, "int", $FILE_ATTRIBUTE_NORMAL, "int", 0) $handle=$h[0] Func SendData($FileName, $LineNumber) ;string to be send $c = readFile($FileName, $LineNumber) $cLenght = StringLen($c) $aArray = StringSplit($c, "") ;_ArrayDisplay($aArray, "", Default, 64) For $i = 1 To $cLenght writeChar($handle, $aArray[$i], $cLenght) Next ;move to next line writeChar($handle, @CR,1) EndFunc ;write a single char func writeChar($handle,$c,) $stString = DLLStructCreate("char str") $lpNumberOfBytesWritten = 0 DllStructSetData($stString, 1, $c) $res = _WinAPI_WriteFile($handle, DllStructGetPtr($stString, "str"), 1,$lpNumberOfBytesWritten) if ($res<>true) then ConsoleWrite ( _WinAPI_GetLastErrorMessage() & @LF) EndIf EndFunc
  8. Thanks for your guidance and help.
  9. Hi, I am trying to get my list displayed in order I press button not in alphabeticall order. I modified example from here Code below. What i want to achieve is to according to pressed button message been displayed in that order. Currently no matter what button in what order I press it is always showing first button NO1 and than button NO2. PLease help. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sMESSAGE = "The following buttons have been clicked" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idAdd = GUICtrlCreateButton("Add1", 64, 32, 75, 25) Local $idAdd2 = GUICtrlCreateButton("Add2", 64, 52, 75, 25) Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $sMESSAGE) Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAdd GUICtrlSetData($idMylist, " button No1|") Case $idAdd2 GUICtrlSetData($idMylist, " button No2|") Case $idClear GUICtrlSetData($idMylist, "") Case $idClose MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit EndSwitch WEnd EndFunc ;==>Example
  10. OK, so i run out of ideas how to make this working. Basically my FIleCOpy statement doesn't do it job. I must be missing something. Here is my code: #RequireAdmin . . Local $fTasks = "C:\Drivers\Other\Tasks\" Local $fTasksSys = "C:\2\" . . . FileCopy(GUICtrlRead($fTasks) & "Win10_CNC_Setup", $fTasksSys, 8) MsgBox(0, "Boot Setting", "Copied Tasks." & $fTasks & "Win10_CNC_Setup" & @CR & "To " & $fTasksSys) FileDelete($fTasksSys & "ADxLR5_StartUp") MsgBox(0, "Boot Setting", "Deleted tasks.") while it is finally creating folder called "2" it does not want to copy files. Files are .xml but without extension one of the is called: "Win10_CNC_Setup". Another thing is I don't understand why this $FC_OVERWRITE + $FC_CREATEPATH doesn't work but if i replace it with this 8 it does create folder. Main question is - how to make it copying files? Please help.
  11. I got same problem but with this bit of code: MsgBox(0,'Window','is activated - C2',1) WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") If Not (WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup")) Then WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") ...why it doesn't want to work?
  12. how to call for silent mode ( i believe is would be done by cmd) in autoit?
  13. Hi, i have below code to install ms visual c++ and .NET, while trying to run .exe created from au3 code i am getting error like: "Runtime Error, R6025 - pure virtual function call." It seems that my code is causing it but no idea what to change to avid it and finish installation successfuly. my code below: ;vcdredist <--Visual C++ Run($sDrivers & "\vcredist_x86.exe") ;waiting for window to be active WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") If Not WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") Then WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") ;control line ;MsgBox(0,'Window','is activated - C1') ;WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") ControlClick("Microsoft Visual C++ 2010 x86 Redistributable Setup", "","[ID:104]") ;control line ;MsgBox(0,'Window','is activated - C2') WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") ControlClick("Microsoft Visual C++ 2010 x86 Redistributable Setup", "","[ID:12324]") Sleep(5000) ;MsgBox(0,'Window','Installing', 1) ;WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") If Not WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") Then WinActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") WinWaitActive("Microsoft Visual C++ 2010 x86 Redistributable Setup") ControlClick("Microsoft Visual C++ 2010 x86 Redistributable Setup", "","[ID:12325]") WinClose("Microsoft Visual C++ 2010 x86 Redistributable Setup") ;NDP461 <-- .NET Run($sDrivers & "\NDP461-KB3102436-x86-x64-AllOS-ENU.exe") WinWaitActive("Microsoft .NET 2015") ;control line ;MsgBox(0,'Window','is activated') ControlClick("Microsoft .NET 2015","",104) ControlClick("Microsoft .NET 2015","",12324) ;final screen WinWaitActive("Microsoft .NET 2015") ControlClick("Microsoft .NET 2015","",12325)
  14. There are some hidden files which i think are being trigged by script - would it be the case it doesn't work? (sorry i dont know how to edit my own post)
×
×
  • Create New...