Jump to content

Recommended Posts

Posted (edited)

Ok. Added changes to version 2.98 and attached modified ComUDF.au3 as of version 2.99.

Changes: 

  Quote

   V2.97
   29/09/2020
        * fixed function _COM_OpenPort() - open port above 9 (the same problem which @Chuckero posted to the forum in 30/09/2020 as V2.93) - Danyfirex
   V2.98
   01/10/2020
        * added function _COM_ListPortDevices - List Port Devices 2DArray - Danyfirex
   V2.99
   17/04/2021
        * added global variable $__g_iCOMUDF_HCOMPortCount as the counter of opened serial ports handles.
          $__g_iCOMUDF_HCOMPortCount is used in _COM_OpenPort and _COM_ClosePort functions (comments added to corresponding functions code).
            The reason: previously, if multiple serial port were open and in use at the same time in one application, the subsequent operation
            of closing one port (which were cause the termination of $__g_hCOMUDF_Kernel32 opened dll handle) rendered the other opened ports unusable
            (receive/send data and close ports operations were unavailable). - Filipp_G
        * modified comments in _COM_SendString function description ("Note" section deleted as inappropriate)   - Filipp_G

Expand  

 

 

ComUDF.au3Fetching info...

Edited by Filipp_G
Set correct and more unique name of variable according variable naming convention. Corrected some comments.
  • 1 year later...
Posted (edited)

Hey

I have a question, is it possible to change the baud without closing and reopening the COM port?

Edited by kmeleon

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

  • 3 weeks later...
Posted

Hi there and thanks for this fine piece of code. 🙂

I just tried the last version v2.99 and had some trouble to open the COM10 port under Win10 (COM1-9 work fine). After a little bit of trial-and-error (I'm not too familiar with Windows-API calls), I narrowed down the point of failure and found a (presumably bad) hack to get it to work by removing the COMx value in the $sDefinition:

; prepare structs and pointer
    Local $tDefinition = DllStructCreate('char Data[255]')
    Local $pDefinition = DllStructGetPtr($tDefinition)

    ; Bugfix-Hack AvN 2023-02-15:
    ; Remove COMx from $sDefinition to get it running with COM10 and above.
    $sDefinition = StringRegExpReplace($sDefinition, "COM\d{1,3} ", "")
    
    DllStructSetData($tDefinition, 'Data', $sDefinition)
    Local $tDCB = DllStructCreate( _
            'long DCBlength;' & _                ; DWORD DCBlength;
            'long BaudRate;' & _                 ; DWORD BaudRate
            'long fBitFields;' & _               ; DWORD fBitFields
            'short wReserved;' & _               ; WORD  wReserved
            'short XonLim;' & _                  ; WORD  XonLim
            'short XoffLim;' & _                 ; WORD  XoffLim
            'byte Bytesize;' & _                 ; BYTE  ByteSize
            'byte parity;' & _                   ; BYTE  Parity
            'byte StopBits;' & _                 ; BYTE  StopBits
            'byte XonChar;' & _                  ; char  XonChar
            'byte XoffChar;' & _                 ; char  XoffChar
            'byte ErrorChar;' & _                ; char  ErrorChar
            'byte EofChar;' & _                  ; char  EofChar
            'byte EvtChar;' & _                  ; char  EvtChar
            'short wReserved1')                  ; WORD  wReserved
    Local $pDCB = DllStructGetPtr($tDCB)

    ; parse $sDefinition and fill the parameters in the prepared DCB struct
    $aCall = DllCall($__g_hCOMUDF_Kernel32, _
            'bool', 'BuildCommDCB', _
            'long_ptr', $pDefinition, _
            'long_ptr', $pDCB)
    If @error Then Return SetError(1, 4, -1)

I neither know why it works with my hack nor I can evaluate possible impacts but I thought I could give a feedback. 🤗

 

  • 7 months later...
Posted

New version:
 

  Quote

   V3.01
   04/10/2023
        * headers / descriptions  / comments - CleanUp - mLipok
        * _COM_ListPortDevices() refactored - mLipok
        * _COM_ListPortDevices() better COM port findings - mLipok

Expand  

 

ComUDF.au3Fetching info...

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 1/25/2023 at 11:29 AM, kmeleon said:

Hey

I have a question, is it possible to change the baud without closing and reopening the COM port?

Expand  

https://stackoverflow.com/questions/5814829/change-serialports-baudrate-while-connection-is-open

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  Quote

   V3.01
   04/10/2023
        * headers / descriptions  / comments - CleanUp - mLipok
        * _COM_ListPortDevices() refactored - mLipok
        * _COM_ListPortDevices() better COM port findings - mLipok
   V3.02
   04/10/2023
        * #include-once - mLipok

Expand  

 

ComUDF.au3Fetching info...

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 1/25/2023 at 11:29 AM, kmeleon said:

Hey

I have a question, is it possible to change the baud without closing and reopening the COM port?

Expand  
  Quote

AT+FPR=<rate> Set command selects the the serial port speed in both directions, from DTE
to DTA and from DTA to DTE. When autobauding is selected, then the
speed is detected automatically.
Parameter:
<rate> - serial port speed selection
0 - autobauding
AT+FPR? Read command returns the current value of parameter <rate>
AT+FPR=? Test command returns all supported values of the parameters <rate>.
Reference ITU T.31 and TIA/EIA-578-A specifications

Expand  

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

New version:

  Quote

   V3.03
   08/10/2023
        * __COM_ClearCommError() - check if error occured - mLipok
 

Expand  

 

ComUDF.au3Fetching info...

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

New version:

  Quote

   V3.04
   10/10/2023
        * _COM_ListPorts() - better COM port findings - mLipok
        * _COM_ListPortDevices() - better COM port findings - mLipok
        * _COM_ListPortDevices() - refactored - CleanUp and sort array - mLipok
 

Expand  

 

ComUDF.au3Fetching info...

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...