so I created my own unit but I'm running into some SIGSEGV exceptions when I try and modify my FIFO variables.
I though the issue was my access of the fifo's "count" variable but removed it and I get it when I modify the in variable.
here are the relative snippets of code
const RawBuffSize = 8192*4;
Type
TThreadFileSave = class(TThread)
private { private declarations }
Raw :record
inpos, outpos:integer;
count :integer;
Buff :Array[-2..RawBuffSize] of byte; // two lead bytes for rap fixes
end;
...
end;
I get the exception when I access raw.inpos with the following after I have copied the new data into my raw.buff[]
function TThreadFileSave.AddToBuff(p: pbyte; Buflen: integer): Boolean;
var pbuf:pbyte;
len, limit,count:integer;
begin
if not assigned(self) then
exit;
result := FALSE; //
if (Buflen < 1) then begin
Showstatus('Buffer add of 0 bytes?');
exit;
end;
...
pbuf := @(raw.Buff[raw.inpos]);
move(p, pbuf, len); // move data into local FIFO works
count := raw.count; // works
inc(count, len);
if (count >= RawBuffSize) then
begin
ShowStatus(' Thread Says buffer overrun.');
count := RawBuffSize;
end;
raw.count = count; // <== exception here
inc(raw.inpos, len); // <== or here if I comment out the line above
if (raw.inpos = RawBuffSize+1) then
raw.inpos := 0 // this works here due to reduction of len before call
else if (raw.inpos > RawBuffSize) then begin
raw.inpos := raw.inpos - RawBuffSize;
ShowStatus('Warning: was not expecting FIFO to wrap in one pass.');
end;
result := true;
end;
I've tried using EnterCriticalsection and LeaveCriticalSection without success. the error hits the on the 1st call.
I define the thread within the VSD class
T_VSD = class
my : record
tag :longint;
BufFile : TThreadFileSave;
...
public
constructor Create;
destructor Destroy; override;
end;
my thread init code and I am also starting the thread before I make the call to AddToBuff above
constructor vsd.create;
begin
...
my.BufFile := TThreadFileSave.Create(true); // suspended until file name is set
...
my.BufFile.OpenFile('rawTest1.bin'); // which has Start built in.
...
my.BufFile.AddToBuff(parameters) // later after testing that OpenFile was successful
any ideals?
MAS