M2C Posted September 15, 2015 Share Posted September 15, 2015 Hello,I'm trying to communicate with a Agilent E3649A DC Power Supply. I have written some code using the CommAPI and so far I am only able to send commands, I cannot receive anything. When I use the application that comes with the power supply everything is working as it should so that rules out the cable. Can someone look over my test code? I may have missed something...#include <CommInterface.au3> #include <MsgBoxConstants.au3> Local Const $iPort = 1 Local Const $iBaud = 9600 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_TransmitString($hFile, "OUTP ON"&@LF) ;Turn output on Sleep (1000) _CommAPI_TransmitString($hFile, "VOLT 7.0"&@LF) ;Adjust voltage to 7 volts Sleep (1000) _CommAPI_TransmitString($hFile, "VOLT 0.0"&@LF) ;Adjust voltage to 0 volts Sleep (1000) _CommAPI_TransmitString($hFile, "OUTP OFF"&@LF) ;Turn output off Sleep (1000) _CommAPI_TransmitString($hFile, "*IDN?") ;Identify your-self Local $sResult =_CommAPI_ReceiveString($hFile, 1, 0);Recieve string _CommAPI_ClosePort($hFile) MsgBox($MB_SYSTEMMODAL, "Title", $sResult, 5)I know that the commands are being sent properly because I can see the output status change on the display of the power supply and my connected LED lights up and then goes out. Also here is a link to the user manual http://cp.literature.agilent.com/litweb/pdf/E3646-90001.pdfThank you in advance!Hello,don't forget the @LF to your requet_CommAPI_TransmitString($hFile, "*IDN?"&@LF) ;Identify your-selfyou can try to change the timeout parameter like thisLocal $sResult =_CommAPI_ReceiveString($hFile, 500);Recieve stringand for testing the port COM, you can use Realterm.exe Link to comment Share on other sites More sharing options...
cabrunco Posted September 17, 2015 Share Posted September 17, 2015 Hello, I am trying to use this UDF, and copied the script by Terribletrux. Sending a string was ok for my device. Reading worked after I modified the timeout parameter, as suggested by M2C. However, I get only very strange characters in the reading. In which format is the data coming? Using commMG by Martin it came directly in Ascii and I had no problem with this. Thank you! Link to comment Share on other sites More sharing options...
Englam Posted November 18, 2015 Share Posted November 18, 2015 (edited) Hello I have a problem.Now, I can use this source code to reboot DUT, but I would like to know how to display all logs and save log. My GUI only displays one log.e.g. If I use tera term , it displays console log and we can save it. How could I know response message whether correct or not.e.g. If we transmitting string "username" and "password", we could login DUT by Autoit. sometimes, we transmitting string "usename" and "password", it displays incorrect username and password. how can I avoid this problem, it seems timer problem. Edited November 19, 2015 by Englam Link to comment Share on other sites More sharing options...
Belini Posted January 23, 2016 Share Posted January 23, 2016 (edited) I'm using AdlibRegister() to draw _CommAPI_ReceiveString() function at regular intervals but sleep and loop can delay this call and I need to call this no matter what the script function is doing, there is a way to do this? EDITED: It would be even better if the received data was treated as an event and _CommAPI_ReceiveString() only be performed when new data were received! Edited January 23, 2016 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Gianni Posted January 23, 2016 Share Posted January 23, 2016 maybe you could use the _WinAPI_SetTimer function. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Belini Posted January 23, 2016 Share Posted January 23, 2016 @Chimp tried using _WinAPI_SetTimer() to draw _CommAPI_ReceiveString() function every 50 milliseconds but the script was too heavy and reached till even paralyze! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Gianni Posted January 23, 2016 Share Posted January 23, 2016 perhaps _CommAPI_ReceiveString() takes too long to finish its task, causing a cycle too "tight" ... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Belini Posted January 24, 2016 Share Posted January 24, 2016 @Chimp I think you are right, then the solution is to know when there is new data to draw _CommAPI_ReceiveString() function will be possible to do this monitor the COM port without using the _CommAPI_ReceiveString()? My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Gianni Posted January 24, 2016 Share Posted January 24, 2016 (edited) Maybe it can be setup a mechanism that should allow this udf to fire events on comm status changes, like already stated in post #51. Unfortunatelly I've found no examples on how things has to be setup to accomplish that, and also I don't know how to do it myself. Here 2 links where there is mention about something like this: http://www.codeproject.com/Articles/2682/Serial-Communication-in-Windows (Search for WaitCommEvent) WaitCommEvent (Waits for an event to occur for a specified communications device) p.s. if some smart mind with a good soul knows how to do it and could post an example, we could be very thankful... Edited January 24, 2016 by Chimp Belini 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Belini Posted January 24, 2016 Share Posted January 24, 2016 Quote Unfortunatelly I've found no examples on how things has to be setup to accomplish that, and also I don't know how to do it myself. I also do not have enough knowledge to start a code of these! Quote if some smart mind with a good soul knows how to do it and could post an example, we could be very thankful... I'm already grateful to you @Chimp for trying to help, now remains only hope that someone with greater knowledge can help! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
GeorgePorgys Posted July 20, 2016 Share Posted July 20, 2016 On 31.03.2014 at 3:27 AM, thoms said: Hi adom, I guess these comports are free : I'm using com0com to make 2 bridges (COM9<->COM10 and COM11<->COM12) and Realterm on each side (COM10 and COM12). I'm in the middle conditioning data from COM9 to COM11 and vice-versa. RealTerm can connect on any virtual comport, ie. COM10 or whatever, but NOT on busy ports. Given that the first com0com bridge is between COM9 and COM10, I've to connect to COM9. If I try the other direction : RealTerm on COM9 and me on COM10, I get the error message. About the other side: COM11 or COM12, I'm really expecting something that works. Is there something else I can check? Thx Thoms Hi Thoms! I used to work with com0com, good one but not enough some features time to time... Now I'm working withVirtual Null Modem (http://www.eltima.com/products/virtual-null-modem/), which is allowed more options for users, like strict baudrate emulation and possibility to create ports for the current user session only. Sometimes it's really very helpful. Link to comment Share on other sites More sharing options...
algiuxas Posted August 26, 2016 Share Posted August 26, 2016 (edited) Where's the download? Edited August 26, 2016 by algiuxas After switching years ago to Linux, sadly I don't use AutoIt anymore. Link to comment Share on other sites More sharing options...
argumentum Posted August 28, 2016 Share Posted August 28, 2016 On 8/26/2016 at 4:45 AM, algiuxas said: Where's the download? https://www.autoitscript.com/wiki/CommAPI ? algiuxas 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
algiuxas Posted August 28, 2016 Share Posted August 28, 2016 (edited) 43 minutes ago, argumentum said: https://www.autoitscript.com/wiki/CommAPI ? Thank you. It works Edited August 28, 2016 by algiuxas After switching years ago to Linux, sadly I don't use AutoIt anymore. Link to comment Share on other sites More sharing options...
argumentum Posted August 28, 2016 Share Posted August 28, 2016 11 minutes ago, algiuxas said: So, I need to copy every script to Include folder? , you'll have to play around with it. Unfortunately I could not find a ZIP with all and examples. algiuxas 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
algiuxas Posted August 28, 2016 Share Posted August 28, 2016 Just now, argumentum said: , you'll have to play around with it. Unfortunately I could not find a ZIP with all and examples. Everything works fine. Don't worry. argumentum 1 After switching years ago to Linux, sadly I don't use AutoIt anymore. Link to comment Share on other sites More sharing options...
antonioj84 Posted March 16, 2017 Share Posted March 16, 2017 hey guys, I am looking for to test (read) if a device is attached to port com2, can someone point me or give me an idea. Thanks ahead Link to comment Share on other sites More sharing options...
Biatu Posted June 27, 2017 Share Posted June 27, 2017 This does not work on latest builds of windows 10 What is what? What is what. Link to comment Share on other sites More sharing options...
techsray Posted July 26, 2017 Share Posted July 26, 2017 (edited) Hello, I am quite sure that I must be doing something wrong while using this UDF. Every time I ran the code (Example-1: https://www.autoitscript.com/wiki/CommAPI_Examples) I got the following error. Any suggestion in figuring out what I am doing wrong will be very helpful. Here is the example that I am trying to run: Example-1: test_CommAPI_Example2.au3 The CommAPI Files that I am using are: 1. CommInterface.au3 2. CommUtilities.au3 3. CommAPIHelper.au3 4. CommAPI.au3 5. CommAPIConstants.au3 6. CommObsolete.au3 Here is my System Information: Autoit version: 3.3.14.2 Architecture type: X64 Opreating System build number: 9600 Service pack info: Opreating System Type: WIN32_NT Oprating System Version: WIN_81 I used the following function to generate this: f_ShowSystemInfo(1) Func f_ShowSystemInfo($iShowMessageBoxFlag = 1) Local $sInfo = " Autoit version: " & @AutoItVersion & @LF & _ " Architecture type: " & @OSArch & @LF & _ " Opreating System build number: " & @OSBuild & @LF & _ " Service pack info: " & @OSServicePack & @LF & _ " Opreating System Type: " & @OSType & @LF & _ " Oprating System Version: " & @OSVersion & @LF ConsoleWrite("System Info" & @LF & $sInfo & @LF) If ($iShowMessageBoxFlag = 1) Then MsgBox(0,"Version Info", $sInfo) EndIf EndFunc Edited July 26, 2017 by techsray Link to comment Share on other sites More sharing options...
techsray Posted November 1, 2017 Share Posted November 1, 2017 On 7/25/2017 at 8:55 PM, techsray said: Hello, I am quite sure that I must be doing something wrong while using this UDF. Every time I ran the code (Example-1: https://www.autoitscript.com/wiki/CommAPI_Examples) I got the following error. Any suggestion in figuring out what I am doing wrong will be very helpful. Here is the example that I am trying to run: Example-1: test_CommAPI_Example2.au3 The CommAPI Files that I am using are: 1. CommInterface.au3 2. CommUtilities.au3 3. CommAPIHelper.au3 4. CommAPI.au3 5. CommAPIConstants.au3 6. CommObsolete.au3 Here is my System Information: Autoit version: 3.3.14.2 Architecture type: X64 Opreating System build number: 9600 Service pack info: Opreating System Type: WIN32_NT Oprating System Version: WIN_81 I used the following function to generate this: f_ShowSystemInfo(1) Func f_ShowSystemInfo($iShowMessageBoxFlag = 1) Local $sInfo = " Autoit version: " & @AutoItVersion & @LF & _ " Architecture type: " & @OSArch & @LF & _ " Opreating System build number: " & @OSBuild & @LF & _ " Service pack info: " & @OSServicePack & @LF & _ " Opreating System Type: " & @OSType & @LF & _ " Oprating System Version: " & @OSVersion & @LF ConsoleWrite("System Info" & @LF & $sInfo & @LF) If ($iShowMessageBoxFlag = 1) Then MsgBox(0,"Version Info", $sInfo) EndIf EndFunc I figured it out. The scripts will work with a small modification at the top. You need to comment out "#NoAutoIt3Execute" from each of the scripts and replace it by the following. ;#NoAutoIt3Execute ; Refer to this forum post for the following change: ; https://www.autoitscript.com/forum/topic/161004-autoit-v33102-runautoitexe-autoit3executeline-issue/?do=findComment&comment=1168605 #pragma compile(AutoItExecuteAllowed, true) The fix mentioned above is necessary and in accordance with the "Change Log": Quote 3.3.9.10 (21st July, 2013) (Beta) AutoIt: - Changed: #NoAutoIt3Execute option replaced with #pragma compile(AutoItExecuteAllowed, true). Default is false. I tested one of the Utility Functions from CommUtilities.au3 and it ran perfectly. After you have made the change, try the following: #include <CommUtilities.au3> Local $sCommPorts = _CommAPI_GetCOMPorts() ConsoleWrite("COM Ports:" & @LF & $sCommPorts & @LF) I hope this helps. The scripts were copied from here: https://www.autoitscript.com/wiki/CommAPI and then corrected. JoeBar and argumentum 2 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