Mail Archives: djgpp/1997/10/07/16:32:44
On Tue, 7 Oct 1997 01:51:27 GMT, Nate Eldredge <eldredge AT ap DOT net> wrote:
>At 05:03 10/6/1997 PDT, Alex Holden wrote:
>>I am just starting a project in DJGPP (A PIC17C75XX programmer), which
>>I want to be able to port to Linux at a later stage. It will use a
>>colour text interface, possibly the mouse, and will need to access the
>>serial port directly (to communicate with the device programmer).
>>The problem is that I have no experience of Linux programming
>>whatsoever, and so I need some advice on exactly what I should do/avoid
>>doing, to make the job of porting the program to Linux as painless as
>>possible.
>If you just want to do vanilla serial port access, you can read and write
>the appropriate /dev/ttySx device. There are ioctl() calls to change the
>baud rate and stuff; see the man pages. If you need to poke the port
>directly, see the "Linux I/O port programming mini-HOWTO".
>> I particularly would like to know how you set up/access the
>>serial port in Linux, and whether it's possible to do direct console io
>>(gotoxy(), intensevideo(), that type of thing).
>I don't think you can, but I could be wrong. If it doesn't *have* to be
>interactive, you could go with the usual Unix tradition of command-line
>invocation with hairy options.
Actually, if one really wants a good library for doing colour console
video with a lot of flexibility, look into [N,PD]Curses. It takes some
getting used to, but this library has functions for gotoxy() type of stuff,
and a lot of other display stuff, as well as allowing non-buffered input
(something which is a difficult thing to do in Linux) and many other
features. It's also a standard on many *nix's and (in the case of
PDCurses), DOS as well. Just a note, there is a bit of a learning curve
(not steep though...), but it affords you with a lot of power for the
portability it provides. PDCurses can be found at DJ's ftp site (under tk/)
and NCurses is usually standard on Linux systems, but can be found on
sunsite and it's mirror's as well.
BTW, another tip for portability... sometimes, you will have to use
#define's and #ifdef's to compensate for platform differences. For example,
when using curses, Linux stores their ncurses library in ncurses/curses.h,
whereas PDCurses on dos is usually just curses.h. So, you'd have to set up
a define like:
#ifdef __LINUX__
#include <ncurses/curses.h>
#else
#include <curses.h>
#endif
Brett.
- Raw text -