IO module library

M

Thread Starter

Mario de Sousa

Hi all, I have just completed a first working version of the library for IO modules I mentioned a few days ago. I also changed the parport driver to use this library. Because of this change the parport driver will now support multi-bit points, which it didn't until now. But before I can commit all this to the cvs, I need to know where to put the io library! I was thinking it should go under io/lib Another possibility is lib/io I prefer the io/lib, as this library is only going to be used by IO modules. Comments please... This library is actually a complete IO module (it includes the main() function) and is only lacking specific functions to actually access the hardware. I expect that in the future this library will handle scaling of analog values, etc... When some new hardware comes along, we can simply write the hardware access functions and link them to this library to generate a new IO module. This also has the benefit that all IO modules will use the same configuration syntax when it comes to defining the mappings between physical IO and plc points. As I expected, the API to hardware access functions has changed, but more on that after I get to commit it to the cvs. By the way, does anybody know offhand the default IO address of the parallel port? The PC I am now using for the PuffinPLC has it at 0x378, but a previous PC I used had it at 0x278. What IO address should I place as the default? (It's easier to ask than to go looking for this info. I'm sure somebody will know offhand...) Cheers,
Mario.
--
---------------------------------------------------------------------------- Mario J. R. de Sousa [email protected] ---------------------------------------------------------------------------- The box said it requires Windows 95 or better, so I installed Linux _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
C

Curt Wuollet

I think there's a utility to discover the PP address. That might be better than the default route. I'll take a look when I get a minute. Regards cww
 
Hey Mario, 0x378 is the standard for "LPT1" in all computers I have used and I have seen it mentioned in several parallel port "HOWTOs" and the like. Here is a good description I found, if not a bit dated ... ~Ken ********************** 3. Addresses, naming, BIOS and DOS IBM defined three standard port base addresses (in 80x86 IO address space). The Printer Adaptor could use base address 0x378, or later 0x278, while the Monochrome Display and Printer Adaptor used base address 0x3BC. The IBM BIOS defines RAM space for 4 parallel printer port base addresses, stored as 4 16 bit words starting at main memory address 0x408. During bootup, the BIOS will check for parallel printer ports at base addresses 0x3BC, 0x378, and 0x278, in order, and store the base addresses of any that are found in consecutive locations in this table. Unused entries may be 0, or some BIOSes fill them with the first port address found. Some software may ignore this table, but it is used by at least the BIOS itself (eg: INT 17, Printer I/O), and by DOS, as described below. The BIOS detects these ports by writing 0xAA to the Data Out register (at I/O address Base+0), reading the Data Feedback register (same address), and deciding there is a port installed if it reads 0xAA. This could be confused if any lines are externally pulled up or down (or if the port defaulted to tristate, or if there is another readback device register at that address). The BIOS also counts the number of parallel ports it found and stores this count in the upper two bits of the byte at 0x411 (yes, the table can hold up to 4 entries, but the BIOS equipment flag printer count only goes to 3). Warning: Just before this table there are 4 words at 0x400 which contain up to 4 entries for base addresses for serial COM ports. At least some serial port software is known to store more than 4 entries, thus overlapping the parallel port table. Hopefully this is rare! DOS (MSDOS and IBM DOS) maps these as LPTn devices. Unlike COMn devices and comm ports, the name mapping varies depending on whether or not there is a Monochrome Display and Printer Adaptor card or not. The first entry in the BIOS table at 0x408 becomes LPT1, the second entry LPT2, and the third entry LPT3 (if there are that many). The DOS device "PRN" is really software alias for another port, by default LPT1; use the MODE command to change this aliasing. The following table has "typical" assignments. Note that by swapping the entries in the BIOS table at 0x408, you can change which physical ports are assigned to LPT1, LPT2, etc. Several "printer swap" programs do just that. Typical Assignments Addr MDPA no MDPA 0x3BC LPT1 n/a Monochrome Display and Printer Adapter (MDPA) 0x378 LPT2 LPT1 Primary Printer Adapter 0x278 LPT3 LPT2 Secondary Printer Adapter _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
Mario de Sousa: > I have just completed a first working version of the library for IO > modules I mentioned a few days ago. I also changed the parport driver to > use this library. Because of this change the parport driver will now > support multi-bit points, which it didn't until now. > But before I can commit all this to the cvs, I need to know where to put > the io library! I vote for lib/io - keep all the libraries together. Probably also put the library file itself directly under lib, so that the shared-lib stuff is all in the same Makefile (I can do that if you prefer). It'll also make it easier if we ever want to quietly migrate functions between the IO library and the main LPLC library. > By the way, does anybody know offhand the default IO address of the > parallel port? man lp :) lp0 is 0x03bc, lp1 is 0x0378 and lp2 is 0x0278. I think the default should be 0x378. Jiri -- Jiri Baum <[email protected]> Connect the power cable, interface cable and ground wire only in the methods indicated in the this manual. It may lead to fire. -- OKIPAGE 8z user's manual _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
M

Mario de Sousa

Jiri Baum wrote: > > Mario de Sousa: > > But before I can commit all this to the cvs, I need to know where to put > > the io library! > > I vote for lib/io - keep all the libraries together. Probably also put the > library file itself directly under lib, so that the shared-lib stuff is all > in the same Makefile (I can do that if you prefer). > Yes. For some reason I was expecting you to say this ;-) What shall I do with the io.c file already there? I think it is only being used by the modbus modules at the moment. Anyway, we should probably re-write them so they use the new io library... > It'll also make it easier if we ever want to quietly migrate functions > between the IO library and the main LPLC library. > I doubt this will ever be the case. But never mind, I'll do as you wish. It doesn't make much difference really. > > By the way, does anybody know offhand the default IO address of the > > parallel port? > > man lp :) Curiously, this morning a psychologist has just shown me a test. It shows how one can get conditioned into looking for complex answers to simple questions. I guess this is another example! :-] The test involves dividing areas, which are not very easy to draw here, so I'll leave it at that... Cheers, Mario. ---------------------------------------------------------------------------- Mario J. R. de Sousa [email protected] ---------------------------------------------------------------------------- The box said it requires Windows 95 or better, so I installed Linux _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
> > Mario de Sousa: > > > But before I can commit all this to the cvs, I need to know where to > > > put the io library! Jiri Baum: > > I vote for lib/io - keep all the libraries together. Probably also put > > the library file itself directly under lib, so that the shared-lib > > stuff is all in the same Makefile (I can do that if you prefer). Mario de Sousa: > Yes. For some reason I was expecting you to say this ;-) > What shall I do with the io.c file already there? For now, leave it there, I guess... (unless you need the filename). It should probably be added to the io library, but you can't do that until the modbus modules get re-written / modified to use the IO library. > I think it is only being used by the modbus modules at the moment. As far as I know, yes. > Anyway, we should probably re-write them so they use the new io > library... Yup. > > It'll also make it easier if we ever want to quietly migrate functions > > between the IO library and the main LPLC library. > I doubt this will ever be the case. Miscellaneous utility functions that start out life in the I/O library but then are needed in non-I/O modules. But you're probably right that it'll be rare. Jiri -- Jiri Baum <> Connect the power cable, interface cable and ground wire only in the methods indicated in the this manual. It may lead to fire. -- OKIPAGE 8z user's manual _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
M

Mario de Sousa

I have been a little busy lately, and haven't found the time to make sure I won't break anything before comiting the io library to the cvs. I'll probably do it on monday. Cheers, Mario. -- ---------------------------------------------------------------------------- Mario J. R. de Sousa [email protected] ---------------------------------------------------------------------------- The box said it requires Windows 95 or better, so I installed Linux _______________________________________________ LinuxPLC mailing list [email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
Top