Receiving data via TINA

  • 1
  • 2
  • 3
  • Seite 3 von 3
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: Receiving data via TINA

 · 
Gepostet: 03.12.2012 - 20:47 Uhr  ·  #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
 
Betreff:

Re: Receiving data via TINA

 · 
Gepostet: 04.12.2012 - 12:14 Uhr  ·  #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
 
Betreff:

Re: Receiving data via TINA

 · 
Gepostet: 04.12.2012 - 12:31 Uhr  ·  #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
Geschlecht:
Alter: 25
Beiträge: 1474
Dabei seit: 03 / 2005
Betreff:

Re: Receiving data via TINA

 · 
Gepostet: 04.12.2012 - 15:33 Uhr  ·  #20
Hi AV.

Zitat

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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: Receiving data via TINA

 · 
Gepostet: 04.12.2012 - 19:41 Uhr  ·  #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
  • Seite 3 von 3
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   93   107 · Page-Gen-Time: 0.041605s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI