cwbudde / comport-library Goto Github PK
View Code? Open in Web Editor NEWCOM Port Library for Delphi (fork from SourceForge)
COM Port Library for Delphi (fork from SourceForge)
I was wondering if the components can be compiled as 64bit?
If this is possible, how should I proceed?
Hi, folks.
Do you have an effective way to disconnect the USB cable?
Unfortunately, all solutions from internet do not work.
Regards
Robert
String converting lost data after #0 symbol
You can't get #0 from port....
property Buffer: string read FBuffer write FBuffer; <<<<<<<<<<<< Here!
procedure TComDataPacket.RxBuf(Sender: TObject; const Buffer; Count: Integer);
var sa:AnsiString; Str: string;
i:Integer;
begin
SetLength(Str, Count);
SetLength(Sa, Count);
Move(Buffer, Sa[1], Count);
{$IFDEF Unicode}
if Length(sa)>0 then
for i := 1 to Length(sa) do Str[i] := char(Byte(sa[i]));
{$ELSE} Str := sa; {$ENDIF} <<<<<<<<<<<< Here!
AddData(Str);
end;
// add custom data to packet buffer
procedure TComDataPacket.AddData(const Str: string);
begin
if ValidStop then
begin
Buffer := Buffer + Str; <<<<<<<<<<<< Here!
HandleBuffer;
end
else
DoPacket(Str);
end;
There is an issue while enumerating available comports and access-violation when closing port.
Returned Stringslist contains additional zeros after portname (here 5x with 10.3.2 and Win 8.1)
This may lead into wrong comparison of a list-entry and a default value: e.g. "COM3ooooo" and "COM3".
The evildoer will be DataLen (in RegEnum) that will return always a value of 10 (here in my setup).
Might be a prob by Microsoft ?!
Next prob is: When i use a 'wrong' port name (with zeros) the designated port will open without error.
But if i close the pot, an access violation occured (reading from adress) !
I couldn't find out the reason yet.
Using 'zero-cleaned' port-names everything is fine.
Here is my modified code :
procedure EnumComPorts(Ports: TStrings);
var
KeyHandle: HKEY;
ErrCode, Index: Integer;
ValueName, Data: array[0..256] of char; // string;
ValueLen, DataLen, ValueType : DWORD;
begin
if NOT Assigned(Ports) then exit;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
'HARDWARE\DEVICEMAP\SERIALCOMM',
0,
KEY_READ,
KeyHandle) <> ERROR_SUCCESS) then exit;
try
Index := 0;
repeat
ValueLen := 256;
DataLen := 256;
ErrCode := RegEnumValue(KeyHandle,
Index,
@valuename, // PChar(ValueName),
ValueLen,
nil,
@valuetype,
PByte(@DaTa), // PByte(PChar(Data)),
@DataLen);
if ErrCode = ERROR_SUCCESS then
begin
Ports.Add(Data); // TmpPorts.Add(Data);
Inc(Index);
end;
until (ErrCode <> ERROR_SUCCESS) ;
finally
RegCloseKey(KeyHandle);
end;
end;
Hi!
How can I send hex values to the comport? I've an array of bytes (for example 6 bytes)...Any help?
I have a Serial Port tracing module (allows me to mimic a loopback).
It shows each character I send:
Comport1.WriteStr('ATZ'#13);
However, all of the OnRx* events - I do a show message for each... even added to your Test\ CPortUTestMainFm - nothing ever fires. Yet, I can open any Windows Terminal program - and when the Port tracing module shows "A", "T", "Z", #13, #10 - the windows terminal programs show: ATZ.
I have tried with Comport v4.11 and your code - neither work. Could someone shed some light - what am I missing??
Hello Christian,
do you plan to create a release for Delphi 11 Alexandria? Thanks.
HOw to sort port by hub port ?
https://i.postimg.cc/bvtHpVKK/2022-06-23-173323.jpg
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.