Receiving data via TINA

  • 1
  • 2
  • 3
  • Page 3 of 3
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Receiving data via TINA

 · 
Posted: 03.12.2012 - 20:47  ·  #17
Hello Andreas,

if you use the ++ option the pointer is incremented (manipulated). If you need the last byte in your buffer you can do this:
because the bufferpointer always points into a buffer which your application must provide you can directly access the last byte of your buffer with

eot:= myBuffer[PacketRecInfo.RecLen-1]; // array access last reveived byte (eot)

btw.
The TINA uses a blocked transfer. It accepts the next Rx package only after the socket is re-enabled. There is no pipe or something else.

rolf
AV
 
Avatar
 
Subject:

Re: Receiving data via TINA

 · 
Posted: 04.12.2012 - 12:14  ·  #18
Thanks again for your answers (-:

The buffer reading still causes trouble.
I did it as you wrote, but get a compiler error.
The compiler doesn't like the ++ and wants to have a semicolon after bufferPtr^.
Code
byte0 := pRecInfo.bufferPtr^++;



... Right now I found a solution.
I wrote it like this:
Code

byte0 := pRecInfo.bufferPtr^;
pRecInfo.bufferPtr++;

Maybe it's useful for somebody.
AV
 
Avatar
 
Subject:

Re: Receiving data via TINA

 · 
Posted: 04.12.2012 - 12:31  ·  #19
IMPORTANT

My code of several posts contains an error!
The variable BuffPtr of the record pRecInfo was written in the wrong way.
You have to add "er" to the variable BufferPtr.

I wanted to correct my code snippets, but unfortunately I can't edit my posts anymore. (There is a time out)
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Receiving data via TINA

 · 
Posted: 04.12.2012 - 15:33  ·  #20
Hi AV.

Quote

Code

byte0 := pRecInfo.bufferPtr^++;




You can only autoincrement a direct pointer, not an indirect one (because of the offset calculations required in the resultant assembler, I think). However you can convert your indirect pointer to a direct one and then carry out your calculations like this

Code

procedure Test( var pRecInfo : tRecInfo );
var
  iPtr : pointer to byte;
  byte0 : byte;
  ....
begin
  iPtr := pRecInfo.bufferPtr;

...
  byte0 := iPtr^++;
...

  pRecInfo.bufferPtr := iPtr;
end; 
;

Obviously not worth it unless you are doing several successive calculations or within a loop.

Regards
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Receiving data via TINA

 · 
Posted: 04.12.2012 - 19:41  ·  #21
or you can directly access your local buffer with:
Code
var
  myBuffer   : array[0..xx] of byte;
...
var
  ptr : pointer;
...
  ptr:= @myBuffer;
  byte0:= ptr^++;
  byte1:= ptr^++;
...
  ptr:= @myBuffer+pRecInfo.RecLen;
  eot:= ptr^;


rolf
  • 1
  • 2
  • 3
  • Page 3 of 3
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   93   107 · Page-Gen-Time: 0.020893s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI