Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy 9 reading data in binary or hex format

Status
Not open for further replies.

dakna

Programmer
Feb 15, 2011
4
MA
Hi ,

i'm developping server applicaion receivinf frames from GPRS/GPS box , the data sent is binary data , my question is , is there any indy function to read these binary data with the assumption that I don't know the size of data, and there no delemiter for theses frames
 
Awfully broad question. Much will depend on how the GPRS/GPS device works. You will want to start there. If the device supports this, there will be a description in the documentation for it.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Hi , forgot all about GPRS box , just I need function to read data in binary format instead of string format , I 'm using method connection.currentreadbuffer but it return data in string format
 
A string can be considered to be an array of bytes if you like, Just use

Code:
var
  b : Byte;
  buffer: String; 
  index: Integer;
begin
  b := Ord(buffer[index]);
end;
 


is not so easy Mr .Griffyn , let me give an example :


we receive string like : #$13#$aa

if we use ord function the result will be : 2123... and so on (each caracter will be converted to it ascii code

but the right result is 13 a 65 (string will contain also non printable caracters)
 
The problem is that a string read function will do exactly that: read for a string and treat the characters encountered in that light. Dakna is in need of more a binary block byte read. What Dakna has is like "Readln(datasource, mystring)", while what he needs is more like "blockread(datasource, mybuffer)".

I don't use Indy 9, so I don't have any suggestions for you other than the one that was made in the other thread.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
What Indy component are you using to read the data? Have you looked at using ReadStream (if available)? It doesn't require you to specify a byte count, and of course, you can use any type of stream.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top