I have an application that uses a serial port component to read and
write data through a USB serial port at 57.6 kb. Originally I used the SerialNG component and with some tweaking I was able to get it to work reliably. But it has problems with Win10, so I changed the code to use ComDrv32, which works when used in a simple TTY demo.
I had to use a separate PChar pointer RecdPtr, and I also had to use an integer for the pointer arithmetic. Apparently Delphi does not allow
RecdPtr := RecdPtr + (DataSize - (MAXCOMM-CommBufferPtr) ); RecdPtr + n
is OK. I'm not sure if I could just advance the DataPtr in the same way, since it is declared as a generic Pointer type.
I tried various settings for the serial port component with inconsistent results. What is consistent is that errors always start when the
CommBuffer is nearly full and the data must be split to fill the buffer
and then start again at the beginning. I may need to check my arithmetic.
In the previous procedure for SerialNG, I did this:
var
RecdPtr: PChar;
begin
RecdPtr := CommSerialPort.ReadNextCluster( NCSize, RdErrors );
...
FreeMem( RecdPtr, NCSize ); // Added 4/8/09
end;
========================================================
I don't know if that was a problem or not. It seems that I might need to reserve memory for the PChar before using it?
P E Schoen schrieb:
You may have already "left the building" at this point, unless you find
this sort of discussion interesting. I have been involved in the
measurement of power line frequency current and voltage signals for a
LONG time, close to 40 years. Technology has changed since then, from
mostly analog methods, then ADCs with early microprocessors like the
8085 and Z80, then signal processing boards with MSDOS, and now PICs and
DSPs with Windows 10 or other OS.
Currently I see similar (but hobbyist) projects in the Arduino forum. I
never tried real time programming on Win32/64, nor did I use COM port components with Delphi. In the early PC days I did some data acquisition using GW-Basic, later with BCB on Win3. I'd no more try to make my hands dirty with real time programs for Windows, and in detail not with Delphi,
be some old reliable (up to D7) or uncomfortable and bloated new (RAD
Studio) versions. It's interesting to hear that you still are in business
:-)
You may have already "left the building" at this point, unless you find
this sort of discussion interesting. I have been involved in the
measurement of power line frequency current and voltage signals for a
LONG time, close to 40 years. Technology has changed since then, from
mostly analog methods, then ADCs with early microprocessors like the
8085 and Z80, then signal processing boards with MSDOS, and now PICs and
DSPs with Windows 10 or other OS.
P E Schoen schrieb:
I tried various settings for the serial port component with inconsistent
results. What is consistent is that errors always start when the
CommBuffer is nearly full and the data must be split to fill the buffer
and then start again at the beginning. I may need to check my arithmetic.
Can't you use multiple buffers, to eliminate the moving of data?
I have considered upgrading to a newer version of Delphi. I have heard
that the even numbered releases (D4 and D6) were buggy and their
odd-numbered successors (D5 and D7) were much better.
I found some
Delphi Enterprise 8 products on eBay for under $200 and CodeGear Delphi
2007 Enterprise for $430. Embarcadero does not offer an upgrade deal
from D4, and their lowest level (Pro) version that offers database
support is $1405. https://www.embarcadero.com/app-development-tools-store/delphi
Perhaps even better is the open source Free Pascal and the Lazarus IDE
that has a look and feel very similar to the Borland Delphi IDE that I
am used to with D4-Pro.
http://wiki.freepascal.org/Lazarus_Documentation https://www.youtube.com/playlist?list=PLB24C56953A79987A
P E Schoen schrieb:
Perhaps even better is the open source Free Pascal and the Lazarus IDE
that has a look and feel very similar to the Borland Delphi IDE that I
am used to with D4-Pro.
http://wiki.freepascal.org/Lazarus_Documentation
https://www.youtube.com/playlist?list=PLB24C56953A79987A
I discontinued watching FPC and Lazarus development. Some Delphi projects
may port easily, others can require much work.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 286 |
Nodes: | 16 (2 / 14) |
Uptime: | 90:54:20 |
Calls: | 6,496 |
Calls today: | 7 |
Files: | 12,100 |
Messages: | 5,277,686 |