Recent

Author Topic: Stopping a program  (Read 2199 times)

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #15 on: June 20, 2019, 09:59:55 pm »
You shouldn't need to add begin/end.  You should be putting the writeln statements into areas that already have those.  Put in several and you should be able to narrow down to the problem area fairly quickly.

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #16 on: June 20, 2019, 11:03:04 pm »
It's in the middle of the program/file.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #17 on: June 20, 2019, 11:11:32 pm »
What is?  Your problem?
If you mean where you want to insert the writeln, that's fine, but it needs to be embedded in code that will execute, you can't just stick it, say, at the top of a procedure that already has a begin/end...it needs to be somewhere between the begin and end statements (e.g. just after the begin, writeln('executing proc whatever'); .

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #18 on: June 20, 2019, 11:47:45 pm »
I was trying to place it between 2 procedures? (not sure of correct terminology) I.E. after an END and before the next BEGIN. That's why I tried adding my own BEGIN and END so it would look like the other procedures, but that didn't work.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #19 on: June 21, 2019, 12:00:06 am »
Do as my previous post explained.  I really think you need to learn a bit about Pascal before you attempt to debug a 25 year old program.  Since you have Lazarus installed try some of the example programs.

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #20 on: June 21, 2019, 01:38:19 am »
BobS: When I said it's in the middle, I was talking to someone else. Thread changed pages and I missed your first reply. I fully aware I'm over my head. This obviously isn't my area of expertise. It was thrown in my lap and I was given a very short window to resolve the issue (plus a bunch of other issues).

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #21 on: June 21, 2019, 08:57:17 pm »
I got a modified version of the writeln command to work today and was able to isolate the part of the code where the error is triggered. Thx all.

It appears one of the modules is reporting that it's in an error state and that's what's triggering the onscreen errors. Still trying to find where the error state data is coming from.

Now I need to figure out how to stop the code execution and report module error status at various points during initialization. For this, I'm thinking the only person that can help is the guy that wrote the s/w and so far he's been unwilling help. What a PITA...

jamie

  • Hero Member
  • *****
  • Posts: 1741
Re: Stopping a program
« Reply #22 on: June 21, 2019, 10:51:40 pm »
Does this program use a Serial port of parallel printer port to talk to the devices?

if so, is it using the PORT[???] function ?

lucamar

  • Hero Member
  • *****
  • Posts: 1943
Re: Stopping a program
« Reply #23 on: June 22, 2019, 01:44:14 am »
Is the code propietary or under a NDA? We may be able to give better help if we could see the code.

Also, can you connect a monitor/keyboard to the tester? That may allow you to develop directly on it, if it has a 386+ and some kind of disk or disk-like storage media with enough space (about 40 MiB for a basic DOS installation of FPC).
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #24 on: June 22, 2019, 03:34:14 am »
Modules connect directly to the tester back-plane. There's 8 digital lines shared between all the modules then all 8 digital lines connect to a thru a CIC card plugged into an ISA or PCI slot on the PC motherboard.  All modules also share 8 address lines. Each module has a set of address switches and each module has a different address.
Code is proprietary.   I've signed a NDA.
No way to connect a monitor or keybd directly to tester.
Not sure what FPC is but hard drive space is very limited (i.e. ~10mB free)

A retired circuit design eng was telling me there's a way to install "checkpoints" in the code but I have no idea how that's done and he doesn't remember how. The s/w guy did all that stuff.

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #25 on: June 22, 2019, 05:53:28 am »
Sounds like you're working under some pretty unreasonable conditions.  What that guy was probably remembering was Turbo Debugger which was introduced in 1989.  It might even be installed on the system.

Otherwise sounds like you're stuck with the old fashioned way, in which writeln is your main friend.  Given the probable age of this program the basic structure is likely something similar to this--with some procedures and functions to do useful repetitive tasks and a main program body that has the overall logic in it (totally fake and very simplified example don't try to compile or run).
program hasaname;

function myfunc(abyte: byte): string;
   begin
     writeln('starting myfunc');
     (*executable code here*)
    (*does something really important stuff here!*)
   end;
procedure dosomething (parameter1: string; parameter2: integer);
var
  avariable, x :byte;
  ava2: string;
  y: integer;
begin
  y:=0; (*initialize y...if your luck code is well commented*)
  (*this is where the executable code is*)
  for x:=1 to 10
    do begin
      writeln('inside loop in dosomething',x);
      ava2:=myfunc(x);
     y:=y+1
   end;

var
   string1: string;
   myint: integer;
begin
  writeln('at start of main program');
  string1:='really vital string';
  myint:=103;
  (*This is the main body of the program*)
  (*Probably a bunch of executable code here*)
  writeln('About to run dosomething.  string1 =',string1,' myint=',myint);
  dosomething(string1, myint);
end.
     
So notice that the writeln debug statements are all inside of the begin/end statements either in the main program or in one of the procedures or functions.  Comments are between (* *) pairs. 

See how the writeln can be used to output the value of variables in various places...that's how it was done before debuggers.

zz28zz

  • New member
  • *
  • Posts: 18
Re: Stopping a program
« Reply #26 on: June 22, 2019, 07:39:49 am »
Unreasonable is a good word for it. Some bosses (non-technical background) seem to believe if you're a hardware guy, then your automatically a s/w guy too.  %)


I believe I have the general idea with writeln. However, I found it was modified a bit so I went with the examples already there. (BIWritelnStr). Seems to work OK.

I've modified the code a bit, but the main parts are still there.

Here's where the error occurs:

If BI_Result(False)>0 Then                                                   <---------- This is what triggers the abort. BI_Result is above 0
         Begin
           BIWritelnStr('line 1274');                                           <---------- I added this
           BIWritelnStr('FAILURE : Abort ramping voltage');      <---------- Displayed error msg.
           Failure:=True;
         End;


When I grep for "BI_Result" I found the Function below. (still trying to make sense of what it's doing) See comments.


(*________________________________________________________
| FUNCTION  : BI_Result
| VERSION   : X.XX
| DATE      : XXXXX XX, XXXX
|.........................................................
| DEFINITION/NOTES:
|     Returns last error number from abort.
|     Reset -  True =  Set BI_ResultVal to 0, plus abort
|                      vars.
|              False = Do not reset BI_ResultVal
|________________________________________________________*)
Function BI_Result(Reset : Boolean) : Word;

Begin
  (* Override abort, forcing powerdown of instruments *)
  If (Insidepwrdwn=True) Or (InsideHVpwrDwn=True)     <---------If in one of the pwr dwn modes, it resets BI_Result to 0
   Then BI_Result:=0
   Else BI_Result := BI_ResultVal;   <-------------If not in a pwr dwn mode, it leaves the BI_ResultVal unchanged
  If Reset=True Then                       <------------What determines if Reset is true or false?????? Seems like if true, error would clear??
  Begin
    BI_ResultVal:=0;                      (* Resets to indicate no error *)      <-------------This comment is orig
    xProcedure:=yUnknown;                            (* Reset xProcedure *)   <-------------This comment is orig
    xSubProc:=yUnknown;                                                                       <---- not sure what's going on from here down
    xBin:=0;
    zBin:=0;
    xNode:=0;
    zNode:=0;
    xPin:=0;
    zPin:=0;
    xUnit:=0;
    zUnit:=0;
    xValue:=1E37;
    zValue:=1E37;
    xDevice:=UFI;                                            (* Uncommon *)
    zDevice:=UFI;
    xHV_Addr:=$FF;
    xHV_OrgData:=$FF;
    xHV_NewData:=$FF;
    zHV_Addr:=$FF;
    zHV_OrgData:=$FF;
    zHV_NewData:=$FF;
    xHV_Value:=0;
    zDataStr:='';
    xDataStr:='';
    GlbAboNodePinValue:=0;
  End;
End; (* Function RI_Result *)
« Last Edit: June 22, 2019, 08:00:57 am by zz28zz »

BobS

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #27 on: June 22, 2019, 08:24:15 am »
It helps when posting code to put it in code tags like this:
Code: Pascal  [Select]
  1. (*________________________________________________________
  2. | FUNCTION  : BI_Result
  3. | VERSION   : X.XX
  4. | DATE      : XXXXX XX, XXXX
  5. |.........................................................
  6. | DEFINITION/NOTES:
  7. |     Returns last error number from abort.
  8. |     Reset -  True =  Set BI_ResultVal to 0, plus abort
  9. |                      vars.
  10. |              False = Do not reset BI_ResultVal
  11. |________________________________________________________*)
  12. Function BI_Result(Reset : Boolean) : Word;
  13.  
  14. Begin
  15.   (* Override abort, forcing powerdown of instruments *)
  16.   If (Insidepwrdwn=True) Or (InsideHVpwrDwn=True) //    <---------If in one of the pwr dwn modes, it resets BI_Result to 0
  17.    Then BI_Result:=0
  18.    Else BI_Result := BI_ResultVal;  // <-------------If not in a pwr dwn mode, it leaves the BI_ResultVal unchanged
  19.   If Reset=True Then                  //     <------------What determines if Reset is true or false?????? Seems like if true, error would clear??
  20.   Begin
  21.     BI_ResultVal:=0;                      (* Resets to indicate no error *)//      <-------------This comment is orig
  22.     xProcedure:=yUnknown;                            (* Reset xProcedure *)//   <-------------This comment is orig
  23.     xSubProc:=yUnknown;                                                      //                 <---- not sure what's going on from here down
  24.     xBin:=0;
  25.     zBin:=0;
  26.     xNode:=0;
  27.     zNode:=0;
  28.     xPin:=0;
  29.     zPin:=0;
  30.     xUnit:=0;
  31.     zUnit:=0;
  32.     xValue:=1E37;
  33.     zValue:=1E37;
  34.     xDevice:=UFI;                                            (* Uncommon *)
  35.     zDevice:=UFI;
  36.     xHV_Addr:=$FF;
  37.     xHV_OrgData:=$FF;
  38.     xHV_NewData:=$FF;
  39.     zHV_Addr:=$FF;
  40.     zHV_OrgData:=$FF;
  41.     zHV_NewData:=$FF;
  42.     xHV_Value:=0;
  43.     zDataStr:='';
  44.     xDataStr:='';
  45.     GlbAboNodePinValue:=0;
  46.   End;
  47. End; (* Function RI_Result *)
  48.  

Anyway this looks like it is called after the error occurs and resets a bunch of global variables to their defaults.  Without knowing what's happening, I'd guess you need to find out where the actual error occurs...where this function is getting called from.
« Last Edit: June 22, 2019, 08:27:04 am by BobS »

trev

  • Full Member
  • ***
  • Posts: 153
Re: Stopping a program
« Reply #28 on: June 22, 2019, 12:27:43 pm »
Quote
If Reset=True Then       <------------What determines if Reset is true or false??????

Answer:

Code: Pascal  [Select]
  1.   Function BI_Result(Reset : Boolean) : Word;

where Reset is a boolean value passed in as BI_Result(True) or BI_Result(False) in the code where the error occurs.
o Lazarus v2.1.0 r61676, FPC v3.3.1 r42640, macOS 10.14.6 (with supplemental update), Xcode 10.3
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.0
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04

jamie

  • Hero Member
  • *****
  • Posts: 1741
Re: Stopping a program
« Reply #29 on: June 22, 2019, 06:53:19 pm »
I understand the code clearly...

It is reporting the current state of the machine and if you decide you want to clear the current
state you need to call that function with TRUE in it..

BI_RESULT(True);

Will Reset it.

However, I think you need to be in a true DOS environment with Dos debugging tools because
I suspect the code is using Port or ASM to read/ write to the cards and unless you have some
port drivers installed the debugging using Laz in windows isn't going to work out to well because
you can't access any of those devices so the error will always be there.

 Do you have port drivers for those cards that allows you to run that code in a non true DOS
environment?