开发者

Ada IO Multiplexing on Linux

I'm trying to learn Ada on Linux by porting simple C++ tools to Ada.

Right now I' trying to write a simple serial communicaton program that sends modem commands and waits for a signalled filedescriptor using select call.

I c开发者_StackOverflow中文版an't seem to find the package containing the select call - do I have to look for some platform specific package here? Where would I find this? Am I even looking for the right thing here?


select() is an OS call specific to Unix, and thus isn't part of Ada's standard library.

You will either need to find a (non-standard) package that provides a Unix system call interface, wrap it yourself using interfacing pragmas, or take a different approach.

For the first option, I can only help a little, since I don't have a Unix system handy. A Posix package should have it, and I believe you can find one such package (Florist) for Gnat here. I can't speak to its quality.

To make your own bindings, you'd want to check out the facilities provided for this in Appendix B of the LRM. This is kind of an advanced topic though, and should not be attempted unless you either know a lot about how your OS does its subroutine linkages, or are ready to learn.

For "a different approach", look into whatever reference guide you are using has to say about Ada's tasking and/or protected objects (not to be confused with the protected keyword in C++). For example, you might prefer to have one task whose sole job is to read incoming data from the serial port. You can synchronize with it between reads via a rendezvous, or to get really sexy, with a queue implemented via protected object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜