Serial Communications interupt chaining. 
Author Message
 Serial Communications interupt chaining.

I have been using the ASYNC unit that Ing. Franz Glaser so helpfully
pointed out to me, I have found it very usefull. Althought I think the
CloseAllComs procedure is possibly not functioning properly, but anyway
thats not what I'm here to talk about:
I have designed a message protocol that consists of TAGS an example of a
tag is <car colour=red>.
I want the program to have an array of strings that acts as a circular
buffer that contains these recieved tags. So that I can use a function
such as ProcessTag(Bottom ofBuffer);
At the moment, the main program is handling the Loading of the Chars
into the circular array and performing validation checks to verify that
the TAG is in a correct format (Length < 255, starts with < and stops
with > etc...)  I would like this to be done by an interrupt. So my main
question is how do I chain from the ASYNC interrupt to my new interrupt.
I think it is possibly by calling a software interrupt, but I'm not
sure? How do I get the ASYNC unit's interrupt to generate the new
software interrupt? I hope whoever reads this is familiar with the ASYNC
unit.


Tue, 14 May 2002 03:00:00 GMT  
 Serial Communications interupt chaining.
Is it right that the ASYNC unit has for each COM an own interrupt handler
written in Pascal? Then you can do the following:
You have to change some things in the Async unit (is that allowed?!?! I
think you have to comment that in the source then).
Make for each COM a procedure-variable in the implementation part of the
unit e.g.

var
 UserHandler : array[0..3] of procedure; { as I remember the Async Unit
handles Com1-4 as 0-3 internal, is that right?
                        if not, simply change it to 1-4 or whatever it is
there... }

Implement a new procedure called

procedure InstallUserHandler(ComNo : byte; Ptr : pointer);
  begin

end;

begin
 fillchar(UserHandler, sizeof(UserHandler), 0); { This is the begin end part
of the async unit. The UserHandler procedurers
                                        are filled with NILs (if a Handler =
NIL then no UserHandler is installed for this port }
end.

In the Hardware-Int-Handlers from the Async Unit you have to add this line
in each one of them:

 begin
     ... { here the usual work of the int handler is done ... }

for the different handlers from 0 to 3, etc. }
 end;

Let me know if this is what you wanted to know and if it works!!

 Bye,
  Tobi



Quote:
> I have been using the ASYNC unit that Ing. Franz Glaser so helpfully
> pointed out to me, I have found it very usefull. Althought I think the
> CloseAllComs procedure is possibly not functioning properly, but anyway
> thats not what I'm here to talk about:
> I have designed a message protocol that consists of TAGS an example of a
> tag is <car colour=red>.
> I want the program to have an array of strings that acts as a circular
> buffer that contains these recieved tags. So that I can use a function
> such as ProcessTag(Bottom ofBuffer);
> At the moment, the main program is handling the Loading of the Chars
> into the circular array and performing validation checks to verify that
> the TAG is in a correct format (Length < 255, starts with < and stops
> with > etc...)  I would like this to be done by an interrupt. So my main
> question is how do I chain from the ASYNC interrupt to my new interrupt.
> I think it is possibly by calling a software interrupt, but I'm not
> sure? How do I get the ASYNC unit's interrupt to generate the new
> software interrupt? I hope whoever reads this is familiar with the ASYNC
> unit.



Wed, 15 May 2002 03:00:00 GMT  
 Serial Communications interupt chaining.

Quote:

> Is it right that the ASYNC unit has for each COM an own interrupt handler
> written in Pascal?

I think it's in Assembly

Quote:
> Then you can do the following:
> You have to change some things in the Async unit (is that allowed?!?! I
> think you have to comment that in the source then).
> Make for each COM a procedure-variable in the implementation part of the
> unit e.g.

> var
>  UserHandler : array[0..3] of procedure; { as I remember the Async Unit
> handles Com1-4 as 0-3 internal, is that right?
>                         if not, simply change it to 1-4 or whatever it is
> there... }

> Implement a new procedure called

> procedure InstallUserHandler(ComNo : byte; Ptr : pointer);
>   begin

> end;

> begin
>  fillchar(UserHandler, sizeof(UserHandler), 0); { This is the begin end part
> of the async unit. The UserHandler procedurers
>                                         are filled with NILs (if a Handler =
> NIL then no UserHandler is installed for this port }
> end.

> In the Hardware-Int-Handlers from the Async Unit you have to add this line
> in each one of them:

>  begin
>      ... { here the usual work of the int handler is done ... }

> for the different handlers from 0 to 3, etc. }
>  end;

> Let me know if this is what you wanted to know and if it works!!

>  Bye,
>   Tobi

I think I get what your saying, What i was going to do was install an ISR on
some software interrupt, and use the original com handler with a slight
modification to call the new ISR when it had completed its original tasks, sort
of like making a BIOS call intr($12); or whatever the pascal equivalent is, I
forget now.


Thu, 16 May 2002 03:00:00 GMT  
 Serial Communications interupt chaining.
I think that's nearly the same. If you call an own software interrupt out of
the hardint handler from the async unit (e.g. INT $60) or you call a far
pointer is nearly the same. It's a bit easier to do it without the soft int,
'cause you have to SetIntVec and GetIntVec and so on. A problem could be
that (even when they are declared as FAR), pascal procedures don't swith the

routines)... But the HardInt handler from the Async Unit surly does this, so
you cann simply make a CALL UserHandler1; in the async assembler routine
(before DS is poped from the stack!).
But then it would be better if you don't declare UserHandler as an array of
procedure. Just declare one pointer for each port:
var
 UserHandler0 : pointer;
 UserHandler1 : pointer;
...

In the InstallUserHandler-procedure you have to CASE comno OF and change the
referring UserHandlerX-variable.
I don't know how to test a pointer if it's NIL in ASM, so you simply can add
a boolean variable for each UserHandler, if
a handler was installed: var Handler0Installed, Handler1Installed, ... :
boolean; and set it TRUE in the InstallUserHandler procedure.

I don't know how the assembler routine of the async unit exactly looks like,
but there should be something like that:

asm
 push DS
 push AX


 mov DS, AX                         { switch the DS segment to the DATA
segment of the program }

 ...
 ...
 CMP HandlerXInstalled, TRUE        { This part is new }

 CALL UserHandler0


 pop AX
 pop DS
 IRET
end;

I hope this will function. If someone sees some errors in this code or has a
better solution, please let  us know !!

Bye,
  Tobi



Thu, 16 May 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. serial communications....

2. Timeout in serial communication

3. REQ: serial communication between 2 pc's using borland pascal for windows

4. pcl4p61.zip Personal serial communications library pascal, MarshallSoft

5. A few questions: problem with FindFirst/FindNext, serial communications and SB/SBPro access - [READ]

6. Serial communications and Parasoft MID

7. Communication on serial port

8. Help with serial communications PLEASE!

9. PLEASE HELP - need serial communication routine

10. Help me: Serial communication

11. A few questions: problem with FindFirst/FindNext, serial communications and SB/SBPro access

12. Borland Turbo 3 Serial Communication problem

 

 
Powered by phpBB® Forum Software