wrapping drivers for Python

Cesar Lopez clopez at abo.fi
Wed Mar 15 10:47:49 EST 2000


I´m want to wrap some drivers that I have running in my system, but I
want use this drivers with pythno programs.

I´ve build and linked statically an external module for my Linux machine
that emulates the behaviour of one of my devices, a green led. But I
don´t know how to access to the low-leve system I only print on/off on
my screen.


If you know how to wrap or access to the low-leve or your machine with
Python tell me.

Here is my driver code:

//led.h

int Setup(int state); // state = 1 --> ON ; state = 0 --> OFF
int static _state;

// Defining communication with the device, Port, Adress, configuration
registers
 and so  on ...
#define PBIOR (*(volatile short int *) (0x5ffffc6))
#define PBCR1 (*(volatile short int *) (0x5ffffcc))
#define PBCR2 (*(volatile short int *) (0x5ffffce))
#define PBDR (*(volatile short int *) (0x5ffffc2))

//led.c
#include "led.h"

int
Setup(int state)
{
PBIOR |= 0x8000;      // Set the bit for output
PBCR1 &= ~0xc000;     // Make it a normal I/0

        switch (state){
            case 1:{
              PBDR |= 0x8000; // Set the LED on
             _state=1; // to read the state of the led
                return 0;
                }
            case 0:{
              PBDR &= 0x0000; // Set the LED off
                            _state=0;
                return 0;
                }
            default: return -1;  // Error: Invalid code
            } //switch
}




More information about the Python-list mailing list