Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/03/20 in all areas

  1. Hi all, I just wanted to let you know my (long-awaited) FMX book is now available (actually it is rolling out on Packt and Amazon so availability may be different across different countries). If you like to read some details you can read my latest blog post: https://blog.andreamagni.eu/2020/10/book-delphi-gui-programming-with-firemonkey-now-available/ I really hope the book will be useful to spread Delphi and FMX as development platform. Thanks for the attention, Andrea
  2. Anders Melander

    Interlocked API and memory-mapped files

    And it's extremely subject to race conditions. https://devblogs.microsoft.com/oldnewthing/20160826-00/?p=94185
  3. Mahdi Safsafi

    Interlocked API and memory-mapped files

    No! CS is not designed to work with inter-process. It may look from the first sight that putting it into a shared memory will do the trick ... but in fact things are more complex than what you think because there is a signaling mechanism involved usually a semaphore that has a local(private) visibility. @Kas Ob. WaitOnAddress apparently works only with threads in the same process.
  4. Anders Melander

    Interlocked API and memory-mapped files

    Why not just use the traditional synchronizations mechanism provided by the OS and keep things simple? It seems pointless focusing on micro optimizing the concurrency control of a buffer backed by virtual memory and accessed synchronously. The sync mechanism is not going to be the bottleneck. I have the code for a shared memory ring buffer somewhere if the OP is interested. I used it a few decades ago to pipe CodeSite log messages between a producer and a consumer service. The consumer wrote the log to disk.
  5. Attila Kovacs

    No C/S FireDac for Delphi Professional

    https://www.devart.com/unidac/
  6. Attila Kovacs

    Reading fields with different lenghts

    it's not necessary to move the data anywhere, just cast the memory to the record type TMyData = record bSTX: Byte; bSep1: Byte; Field1: Word; bSep2: Byte; Field2: Array [0 .. 5] of Byte; bSep3: Byte; Field3: Array [0 .. 2] of Byte; Field4: Array [0 .. 4] of Byte; bsep4: Byte; bETX: Byte; bLRC: Byte; end; PMyData = ^TMyData; var DataFromCOM: TBytes; begin SetLength(DataFromCOM, SizeOf(TMyData)); DataFromCOM[2] := 122; WriteLn(PMyData(DataFromCOM).Field1.ToString); ReadLn; end.
  7. David Heffernan

    Reading fields with different lenghts

    Beyond the compilation error which is just a typo, pointless to zeroise the record and then write over those zeros.
  8. Clément

    Reading fields with different lenghts

    Hi, Showing some code always helps us give accurate answers. Anyway.... If you can read Sizeof(TMyData) in one peace, you could use a record like type TMyData = record bSTX : Byte; bSep1: byte; Field1: Array[0..1] of byte; bSep2 : Byte; Field2 : Array[0..5] of byte; bSep3: Byte; Field3 : Array[0..2] of byte. Field4 : Array[0..4] of byte; bsep4 : Byte; bETX : Byte; bLRC : byte; end; var MyData : TMyData; begin fillchar( MyData, Sizeof(TMyData) , 0 ); move( DataFromCOM[0], MyData[0], Sizeof(TMyData) ); // Use the data MyData.Field1; MyData.Field2; end; Always check if you are receiving the expected number of bytes. Check the values of STX, ETX and the separators to see if at least those are Ok. If this routine will be called "a lot", I suggest creating MyData as a class field, to be use as long as the class is not destroyed.
  9. Attila Kovacs

    Reading fields with different lenghts

    @AndrewHoward cast the data to a corresponding packed record
  10. David Heffernan

    Reading fields with different lenghts

    If the fields are at known, fixed positions then you can read them directly. If not then you need to parse the data.
  11. In a set of projects, you have to handle differently the source for each of the individual projects and the source for libraries, components and other common files. I have a common base for everything, then a subdirectory for libraries, components and common files, then a sub-directory for all projects. The library sub-directory has one sub-directory for each group of sources (A library or component can be made of several sources). The project sub-directory has one sub-directory for each project. In the sub-directory for each project, I have different directories: for sources, for docs, for dcus, for binaries, for images,... I never use search path in projects: I always add each required unit in the project. This way I see what the project really need. When creating a project which is similar to an existing one, I first work on the existing one to split as much as possible the sources: some which are specific to that project and other sources which will be common. Then I move the new common files to the library directory in an appropriate sub-directory. Then I using the IDE save the project file to the directory where the new project will live and then, using the IDE, I save all specific files to the same directory. This must be done in that order so that the original project stay untouched. I tend to have many source files of small size. Each file contain only things that are needed for the file main purpose.
×