Jump to content
Sign in to follow this  
dainiusb

Send string to Arduino

Recommended Posts

So I'm trying to send a string of data to Arduino using CommMG UDF. It seems that Arduino is not receiving it. I used Device Monitoring Studio and it shows that the data is sent fine and looks exactly the same as if I sent it from Arduino Serial Monitor. Is CommMG compatible with USB?

Global $CMPort = 9
Global $CmBoBaud = 9600
Global $sportSetError = ''
Global $CmboDataBits = 8
Global $CmBoParity = "none"
Global $CmBoStop = 1
Global $setflow = 2

_CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow)

If @error Then
    MsgBox(16,"Error!","Can't connect to Arduino on port - "&$CMPort)
    Exit
EndIf

_CommSetRTS(0)
_CommSetDTR(0)

_CommSendString("x" & 128 & "y" & 256 & "e", 1)

 

Edited by dainiusb

Share this post


Link to post
Share on other sites
30 minutes ago, dainiusb said:

Is CommMG compatible with USB?

It should be.  I've used it and seen it used for other "Arduino" serial comm.

Does the _CommListPorts function display the port you are trying to connect to?


Share this post


Link to post
Share on other sites
7 minutes ago, spudw2k said:

It should be.  I've used it and seen it used for other "Arduino" serial comm.

Does the _CommListPorts function display the port you are trying to connect to?

Yes. But now it started to work. I don't know what happened.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By Codenameglassy
      Hello so i need help, so i have a while(1) Loop but i want to restart the loop form the begining if a specific event occurs or what i want on screen is occured.. i want  to restart the loop from beginning , leaving the rest of the script.
      But if the event didnt occur it follows the rest of the script and goes on while loop..
    • By TrashBoat
      Im trying to iterate through a 2d array created by 
      ProcessList() function that returns a 2d array containing names and pid's, i wanted to filter through the names and delete entries that have "svchost.exe" and this is how i did it
      Func _Sanitize($array) For $x = 1 To UBound($array) - 1 ConsoleWrite($array[$x][0] & @CRLF) If $array[$x][0] == "svchost.exe" Then _ArrayDelete($array, $x) EndIf Next EndFunc ;==>_Sanitize And i get this error message
      What is wrong?
    • By gahhon
      Global Const $DIR_WA_FOLDER = @MyDocumentsDir & '\Whatsapp Extension' Global Const $DIR_SHORTCUT = @DesktopDir & '\WhatsappWeb.exe' Func _Create_Shortcut() Local $sMessage = "Creating shortcut " _Metro_SplashTextScreen(1, "", $sMessage) AdlibRegister("_Metro_LoopInProgress") If FileExists($DIR_WA_FOLDER) Then $iDelete = FileDelete($DIR_SHORTCUT) If $iDelete Then _FileWriteLog($LOG_INSTALLATION, "Debug: Desktop's shortcut is deleted.") Else _FileWriteLog($LOG_INSTALLATION, "Debug: Desktop's shortcut is not found. But, desktop's shortcut is still created.") EndIf If FileExists($DIR_WA_FOLDER & '\WhatsappWeb.exe') Then $iCreate = FileCreateShortcut($DIR_WA_FOLDER & '\WhatsappWeb.exe', $DIR_SHORTCUT) If $iCreate Then _Metro_MsgBox(0, "", "Desktop shortcut is now created!") _FileWriteLog($LOG_INSTALLATION, "Debug: Desktop's shortcut is created.") Else _Metro_MsgBox(0, "", "Desktop shortcut is failed to created!") _FileWriteLog($LOG_INSTALLATION, "Error: Fail to create shortcut.") EndIf Else _Metro_MsgBox(0, "", "Source not found!") _FileWriteLog($LOG_INSTALLATION, "Error: WhatsappWeb.exe is not found.") EndIf Else _Metro_MsgBox(0, "", "Source not found!") _FileWriteLog($LOG_INSTALLATION, "Error: Whatsapp Extension folder is not found.") EndIf AdlibUnRegister("_Metro_LoopInProgress") _Metro_SplashTextScreen(0) EndFunc So I do have a button to trigger this create shortcut to desktop.
      But after it created shortcut at desktop, I cannot execute the shortcut as it has no any response.
      Then I go try trigger the file at the source path @MyDocumentDir & '\Whatsapp Extension\WhatsappWeb.exe' and it work as expected.
      Then I go to check my log, and it shows:- (P/S: I already did trigger the function twice)
      2019-02-28 23:27:32 : Debug: Desktop's shortcut is not found. But, desktop's shortcut is still created. 2019-02-28 23:27:33 : Debug: Desktop's shortcut is created. 2019-02-28 23:28:40 : Debug: Desktop's shortcut is not found. But, desktop's shortcut is still created. 2019-02-28 23:28:41 : Debug: Desktop's shortcut is created. So based on my log shows, it failed to locate the shortcut, but it did exists there.
       
      P/S: This project is done developed weeks ago, every testing is passed. Is just somehow the executable cannot be execute.
       
       
      Any advise?
    • By chrweav86
      Here is an existing AS400 PCOM script that I have: 
      #include-once
      #cs ----------------------------------------------------------------------------
       UDF Header Title: _PCOMM
       UDF Header Version: 0.1.0
       AutoIt Version: 3.3.8.1
       Author:         Jason S. - Jewelry Supply, Inc.
       Script Function: PCOMM UDF Header
                          For use with IBM AS/400 - IBM OS/400 - IBM System i - IBM i application system.
                          This PCOMM UDF Header targets ASW - an ERP application suite written in IBM's RPG language (yuck!),
                          although it will work for any AS/400 system and is not ASW specific.
                          PCOMM allows injection of keystrokes into the datastream of
                          a running terminal/console application ("Green Screen" Console Emulator).
                              - Assumes Session 'A' but can be overriden using the aswConnect() function.
                          PCOMM allows observing of characters in the datastream of a running
                          terminal/console application ("Green Screen" Console Emulator).
                              - Assumes Session 'A' but can be overriden using the aswConnect() function.
      #ce ----------------------------------------------------------------------------
      Global $Session = "A"
      Global $Ps
      Global $Oia
      ; Specify session to connect to
      Func aswSetSession($nSession)
          $Session = $nSession
      EndFunc
      ; Connect to ASW
      ; @param $nSession - Specify session to connect to. Ex: "A"
      Func aswConnect($nSession = $Session)
          $Obj_ConnMgr = ObjCreate("PCOMM.autECLConnMgr")
          $OBJ_EmulSession = ObjCreate("PCOMM.autECLSession")
          $OBJ_EmulSession.SetConnectionByName($nSession)
          $Ps = $OBJ_EmulSession.autECLPS
          $Oia = $OBJ_EmulSession.autECLOIA
      EndFunc
      ; Send Data to ASW
      ; if $rownum and $colnum are not specified, defaults to the cmd line
      Func aswSend($keys, $rownum = 20, $colnum = 7, $inhibit = 1)
          $Ps.SendKeys($keys, $rownum, $colnum)
          if $inhibit = 1 Then
              While $Oia.InputInhibited <> 0
              WEnd
          EndIf
          $Oia.WaitForInputReady()
      EndFunc
      ; Get Data from ASW
      Func aswGet($row, $col, $length)
          $info = $Ps.GetText($row,$col,$length)
          return $info
      Endfunc
      ; Check which page we are on
      ; @param $page - Page to see if we are on. Ex: "DMR30101" == Sales Order Maintenance page
      Func checkScreen($page, $rownum = 1, $colnum = 72, $length = 8)
          If StringInStr(aswGet($rownum, $colnum, $length), $page) Then
              Return 1
          Else
              Return 0
          EndIf
      EndFunc
      I would like to use it launch a connection to the AS400. I have an executable that I run with an hod file. Do I just need to run the exe and hod file then run the session connect function and send keys function to pass credentials?
       
    • By FordsFinest
      Have come across an issue where I use the below code to select and then click an item. It works great on every computer but one, which happens to be my bosses computer (of course right lol).  So SelectItem works fine, but for some reason, the ClickItem command keeps clicking the item below the correct item (but only on this computer. I changed the command to controlsend instead, but i'd rather use the click option.. any ideas here?
       
      _GUICtrlTreeView_SelectItem($hWnd, $Array2[1]) _GUICtrlTreeView_ClickItem($hWnd, $Array2[1], "right")  
×
×
  • Create New...