Jump to content

Recommended Posts


I´m making a script to send and receive data to/from Bluetooth serial, but I´m having a problem to connect to the com port.

The problem is that I´ve two ports, one is the COM4 and the other is COM6 (not using at the same time)

COM4 is a standard com port thought USB port that I can connect using CommMG, it´s working fine.

_CommSetPort($port, $sportSetError, 9600, 8, 0 ,1,0)

COM6 is a Bluetooth serial, that only works (I mean I can connect, send and receive data) with _WinAPI_CreateFile.

$openport = _WinAPI_CreateFile("COM6", 2, 6)
 . . .
 _WinAPI_ReadFile($openport, DllStructGetPtr($tBuffer), 1, $nRead)
 $sText = BinaryToString(DllStructGetData($tBuffer, 1))


If I try to connect the COM4 with _WinAPI_CreateFile it´s not working... and when I try to connect with CommMG to COM6 it´s give a -16 (Port not found) error..

The problem is:

How can I open/connect to the bluetooth (COM6) port using CommMG  ( to write one single script instead of two - one using CommMG and another using  _WinAPI_CreateFile)...


Thanks in advance!

Edited by lesther
added details
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mmoalem
      Hi there - creating a simple script to triger cctv software to turn on when my phone is not connected to home wifi. But having issues with my phone (samsung s7) not answering ping when sleeping (despite wifi set to work when sleep) - not sure the issue... and ideas? 
      Alternatively was wondering about pinging the bluetooth address of the phone - anyway to get this working in autoit?
    • By dainiusb
      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)  
    • By willindows
      Hello everyone, I usually use the include commMg.au3 to control the Arduino through some COM port via serial,  in previous versions of Windows until version 8.1 works perfectly. Recently I updated my windows to version 10 and when I use this include no longer works and the error that appears is "Port does not exist." Someone is going through a similar situation? Please can help me solve?
    • By stormbreaker
      Hello everyone. This is my second tool concerned with Bluetooth Technology. It uses native windows bluetooth functions to discover bluetooth devices near you.

      Workable for all devices supporting Plug-And-Play in Windows. Download here (source code included).

      All suggestions are welcome.
    • By stormbreaker
      Hello everybody, this is my first example script weeks after giving my exams. Here is it:

      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Bluetooth Manager (just something)", 409, 135, 192, 124) $Label1 = GUICtrlCreateLabel("This script will check if your PC is bluetooth enabled.", 8, 8, 368, 17) $Button1 = GUICtrlCreateButton("Check if device present", 112, 48, 171, 25, $WS_GROUP) $Checkbox1 = GUICtrlCreateCheckbox("Disable Discovery for all Bluetooth Devices on PC", 16, 96, 257, 17) $Button2 = GUICtrlCreateButton("Exit", 312, 96, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableIncomingConnections", "Handle", 0, "Bool", 1) If $RESULT[0] = 1 then msgbox(64, "Message", "Congrats! Your Computer is bluetooth enabled.") else msgbox(16, "", "No device found") EndIf Case $Checkbox1 If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 0) msgbox(64, "", "Discovery Disabled.") Else $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 1) msgbox(64, "", "Discovery Enabled.") EndIf Case $Button2 Exit EndSwitch WEnd
      It can check if your PC is bluetooth enabled and can switch between bluetooth discovery modes. All functions taken from Microsoft's bthprops.cpl

      Constructive suggestions are always welcome

      Note: Bluetooth discoverability can be controlled as long as the script is running. Once terminated, bluetooth state changes back to previously set by user. This is a Microsoft bluetooth function issue.

      EDIT: This script is only meant for discovering Bluetooth Radios on a PC. That's all.
  • Create New...