Jump to content

giannis121

Active Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by giannis121

  1. Danyfirex, thanks for the response. I have some new details to share: When I'm running the manufacturer's communication software, it works well. If within a few seconds after closing this software, I'm running my code, I get the response I want from the device. But only for one time. So, seems to me that there's problem somewhere else, not on the transmit and receive function, although I don't get any @error message from the functions. #include <CommInterface.au3> #include <MsgBoxConstants.au3> Local Const $iPort = 2 Local Const $iBaud = 19200 Local Const $iParity = 0 Local Const $iByteSize = 8 Local Const $iStopBits = 2 Local $hFile =_CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits) if @error<>0 then msgbox(0, "Error", "Error: " & @error) EndIf _CommAPI_ClearCommError($hFile) _CommAPI_PurgeComm($hFile) _CommAPI_TransmitBinary($hFile, 0x5A) _CommAPI_TransmitBinary($hFile, 0x01) $sResult1 =_CommAPI_ReceiveBinary($hFile, 1, 0) $sResult2 =_CommAPI_ReceiveBinary($hFile, 1, 0) $sResult3 =_CommAPI_ReceiveBinary($hFile, 1, 0) _CommAPI_ClosePort($hFile) MsgBox($MB_SYSTEMMODAL, "Result:", $sResult1 & " " &$sResult2 & " " & $sResult3 , 5)
  2. If you have any idea, please share: I should receive 3 bytes starting with the byte 0x07, but I am receiving only one byte (0x05). (The program that i have from the manufacturer works fine.) #include <CommInterface.au3> #include <MsgBoxConstants.au3> Local Const $iPort = 2 Local Const $iBaud = 19200 Local Const $iParity = 0 Local Const $iByteSize = 8 Local Const $iStopBits = 2 Local $hFile =_CommAPI_OpenCOMPort($iPort, $iBaud, $iParity, $iByteSize, $iStopBits) _CommAPI_ClearCommError($hFile) _CommAPI_PurgeComm($hFile) _CommAPI_TransmitBinary($hFile, 0x5A) _CommAPI_TransmitBinary($hFile, 0x01) Local $sResult =_CommAPI_ReceiveBinary($hFile, 1, 0) _CommAPI_ClosePort($hFile) MsgBox($MB_SYSTEMMODAL, "Result:", $sResult, 5)
  3. Allow2010, there should be one function called _CommAPI_TransmitData, but there is no in the CommInterface.au3 file. Am I right?
  4. Sorry, i posted at wrong place, but i can't remove it. Any of the admins can do it?
  5. The comminterface.au3 as downloaded from https://www.autoitscript.com/wiki/CommAPI, doesn't contain the _CommAPI_TransmitData function that is mentioned on many of your programs posted above. Where can i find the complete file???
  6. Can someone post a small script on how to send and receive hex bytes? I am actually trying to connect to an external virtual com port and i am not getting proper acknowledge from the device. I want to send 4 bytes and I should receive 2 bytes FF 00 acknowledge. With a com monitor, i can see the 4 bytes are sent but the acknowledge is 0x5A. Do I have bad timing? How can i solve it? #include <CommMG.au3> $result=_CommSetDllPath("C:\Program Files (x86)\AutoIt3\Include\commg.dll") if $result=-1 Then MsgBox(0, "Dll path", "Dll not found.") _CommSetport(2, $result, 19200, 8, 0, 2, 2) _CommSendbyte(0x5A) _CommSendbyte(0x02) _CommSendbyte(0x00) _CommSendbyte(0x01)
  7. I'm still trying to communicate with this device, but seems that I need some help. #include <CommInterface.au3> $hFile=_CommAPI_OpenCOMPort(2, 19200, 2, 8, 2) if $hFile=0 Then MsgBox(0, "ERROR", @error) _CommAPI_TransmitBinary($hFile, 0x5A) _CommAPI_TransmitBinary($hFile, 0x01) $data=_CommAPI_ReceiveBinary($hFile) msgbox(0, "data", "data= " & $data) _CommAPI_ClosePort($hFile)I have a com-port monitor software and i can see that the data are transmitted, put there is no any data received. Normally I should receive 3 bytes, but there is no feedback. Do I miss the sequence? I need some help, if anyone has used the comport functions. I also tried the UDF from this post, with the same luck:
  8. I need some information on how to start with com port communication. Recently I bought a USB-ISS (it's a USB to I2C device: http://www.robot-electronics.co.uk/htm/usb_iss_tech.htm). It's connected as Virtual COM port. So, I need some help to start exchanging data with the device. Can you help me start? Giannis
  9. I don't know what was the problem, but finally FileInstall works and i like it! Zedna, i followed your link, but all seems chinese to me! (i won't say greek) Thank you for your time!!! Giannis
  10. This is the code: #NoTrayIcon #include <File.au3> $sn=DriveGetSerial("c:\") $data="2024750000" If $sn = $data Then FileDelete("c:\test_file.txt") FileInstall("c:\test.exe", "C:\test_files\test-code.exe", 1) ShellExecute("C:\test_files\test-code.exe") WinWaitActive("test-code") WinWaitClose("test-code") FileDelete("C:\test_files\test-code.exe") Else MsgBox(0, "Wrong Serial Number.", "Wrong Serial Number.") EndIf Do your magic Melba, you have saved me in the past again!
  11. I get an error when converting to .exe: Error Adding file: c:\test.exe The test.exe exists on C. Why can that be? Regards, Giannis
  12. ok. My reduced lexikon is also a problem that can't be solved(!!!) I have an executable file that was not created by me (so i don't have the source code). This is the test.exe. I want to execute some code, and then run this test.exe. Matter of protection, the code before the test.exe will check the hard disk serial and if it is correct, will run the test.exe. This is the new exe file: $sn=DriveGetSerial("c:") $data="bla bla bla" If $sn = $data Then FileDelete("C:test_file.txt") ShellExecute("C:test.exe") EndIf Now i want to create only one file (the test.exe will be included to the new exe), so nobody will be able to run seperatelly the test.exe without the check of serial No. So, i think that the point is given now. I want to include and executable inside one other, by creating only one exe. Hope my Imagination does not exceed reality... Giannis
  13. No this is not what i am looking for, while FileInstall needs also the test.exe to be somewhere. I need the test.exe to be included to the new exe file. Is it now more clear? Thank you... Giannis
  14. My will is to run an executable file doing some things, including running another exetutable and finally create only one file. For example: #include <File.au3> FileDelete("c:\test_file.txt") ShellExecute("C:\test.exe") My problem is how to create only one file that will include the exe file. Any suggestions?
  15. Seems like the problem is solved. Now i don't delete the file. I use OpenFile with flag 2, as BrewManNH suggests. Let me check better and i will come back to tell you what is going on finaly. Works very good! Thank you is a small word....lol
  16. Hi amazing forum! I face a problem that i can't solve. Please if you have some time to find the problem, give me any suggestion... The program deletes 2 files, runs an executable that creates the files again. Then it reads the first file and writes to the second if there are some strings found. The problem is that i find at the "write_here.txt" file, numbers next to numbers (example: 123123), which means that the @CRLF didn't work. Or other times i find numbers allready writen (example: 0 3 14 21 0 3 0) Other times it works fine! FileDelete("c:\write_here.txt") FileDelete("c:\read_from_here.txt") ShellExecute("C:\create_file.exe") WinWaitActive("create_file") WinWaitClose("create_file") If FileExists("c:\read_from_here.txt") Then $sInput = FileRead("c:\read_from_here.txt") $File=FileOpen("c:\write_here.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($File, "0"&@CRLF) ;Write 0 at first line ; Split into lines $aInput_Lines = StringSplit($sInput, @CRLF, 1) ; Take each line in turn For $i = 1 To $aInput_Lines[0] if StringInStr($aInput_Lines[$i], "COMMAND1")>0 Then ;if it finds this word if StringInStr($aInput_Lines[$i-1], "COMMAND2")>0 Then ;and the previous line has this word FileWrite($File, $i-2&@CRLF) ;then write the number of the line to the "write_here.txt" file EndIf EndIf Next FileWrite($File, "9999") ;Last line write 9999 FileClose($File) EndIf Any ideas would be helpful!!!
  17. I found a solution by using the code of this post: Thank you very much!
  18. The bitmap is accessible in normal conditions. I don't know if it is when windows start...It is placed on the same drive with the application. And how can i check when the shared network is ready?
  19. I got inside Task Manager and checked some executables running by windows,like csrss.exe, explorer.exe, winlogon.exe (of course i don't know what each do), but was just a thought. Maybe i should wait until something that has to do with the screen will be loaded and then start my application. Any ideas? Giannis
  20. I have made an exe file that starts an application when the pc is starting. This application first shows a bitmap for a few seconds (while loading) and then starts normal. The problem is when it runs by itself (from the startup) the bitmap is shown black the first time. I have tried ProcessWait and have checked all the processes but still the same. If i use a pause (like sleep) a long time (20sec), it starts good. But i want the application to start immediately after desktop is ready. The OS is Win7. Any ideas will help! Thank you, Giannis
  21. Thank you Yashied! Simple and easy to be used!
  22. It is really very useful. Thank you! But... I need something more, like having big buttons for opening, big slider and location line (the circled positions on the attached file). Maybe sounds crazy, but if i can do it, would be good. Any ideas or keys? Regards, Giannis (And by the way, i like your profile photo! lol)
  23. I would like to have large icons and buttons at FileOpenDialog function, to use it in a touch screen. Do you know how i can do that? Regards, Giannis
  24. Thank you all very much! Finally i used FileRead(), StringRegExp() and FileWriteToLine(). The only thing is that i had to "FileRead" two times, while when i was inserting the new line (two lines above the found string) the line counting was changed. So before the second word search, i "FileRead" again. Here is the code (i dont know if it can be written in shorter way). Just works... Happy new year everyone! $aInput_Lines = StringSplit(FileRead("file.txt"), @CRLF, 1) $Line=0 ; Take each line in turn For $i = 1 To $aInput_Lines[0] _StringBetween($aInput_Lines[$i], "A", " "&" ") if @error=0 Then _FileWriteToLine("file.txt", $i+$Line-3, "word1") $Line=$Line+1 EndIf Next $aInput_Lines = StringSplit(FileRead("file.txt"), @CRLF, 1) $Line=0 ; Take each line in turn For $i = 1 To $aInput_Lines[0] _StringBetween($aInput_Lines[$i], " Y", " ") if @error=0 Then _FileWriteToLine("file.txt", $i+$Line-3, "word2") $Line=$Line+1 EndIf Next
  25. Please help me do the following: I want to find inside a txt file some words and then go back 2 lines and add some text. The 2 words that i will look for, are not standard. the first one begins with "A X" and ends with " " and the second one begins with "A Y" and ends with " " After finding the words, there will be added a text 2 lines before: "word 1" for the 1st and "word 2" for the 2nd. Can you help on this?
×
×
  • Create New...