From: Toby C. <tco...@pl...> - 2008-01-30 04:26:59
|
to run it you just need to specify the .so file in player cfg file, have a look at the example cfg file. Toby On 30/01/2008, mojahid haque <moj...@ya...> wrote: > > Hi, > thanks for your mail. I already make drioDriver.so file by using command > > > $ g++ -shared -o drioDriver.so `pkg-config --cflags playercore` > drioDriver.cc `pkg-config --libs playercore` > > > > So next what i shall do for plugin my relay. How i shall test my relay > ?. I never use makefile system compile. I do not know how to compile > makefile system .Is it ok. I get just drioDriver.so in my directory. > pls pls help me. > best regards > ASM. Hoque > > DCU > Ireland > > > > ----- Original Message ---- > From: Toby Collett <tco...@pl...> > To: mojahid haque <moj...@ya...> > Sent: Tuesday, 29 January, 2008 6:19:44 PM > Subject: Re: About Relay Driver > > You need to build drivers as shared objects (.so in linux) rather than as > executable programs. Have a look at the Makefile.example in the player > example plugin driver directory for the correct flags. > > Toby > > On 30/01/2008, mojahid haque <moj...@ya...> wrote: > > > > Hi Toby, > > thank you for your instraction. > > I already write one driver for relay. which manual you can find here > > http://www.bb-europe.com/product.asp?SKU=232DRIO. > > > > the programme is > > > > > > > > #if > > HAVE_CONFIG_H > > > > #include <config.h> > > > > #endif > > > > #include > > <fcntl.h> > > > > #include > > <string.h> > > > > #include > > <termios.h> > > > > #include > > <unistd.h> > > > > #include > > <libplayercore/playercore.h> > > > > /* the class for the driver*/ > > > > #define > > DEFAULT_DRIODRIVER_PORT "/dev/ttyS0" > > > > #define > > DEFAULT_DRIODRIVER_PORT_RATE 9600 > > > > > > > > > > > > class > > drioDriver : public Driver > > > > { > > > > public: > > > > // Constructor; need that > > > > drioDriver (ConfigFile* cf, int section); > > > > ~drioDriver (); > > > > // Must implement the following methods. > > > > virtual int Setup(); > > > > virtual int Shutdown(); > > > > virtual void Main(); > > > > // This method will be invoked on each incoming message > > > > virtual int ProcessMessage(MessageQueue* queue, > > > > player_msghdr * msghdr, > > > > void * data); > > > > virtual int Subscribe (player_devaddr_t id); > > > > virtual int Unsubscribe (player_devaddr_t id); > > > > private: > > > > // dio state data > > > > player_devaddr_t dio_id; > > > > player_dio_data_t data, prev_data; > > > > // Publish state data . > > > > void PutData(void); > > > > const char* serial_port; > > > > int port_rate; > > > > // Port file descriptor > > > > int fd; > > > > // Initial serial port attributes > > > > struct termios initial_options; > > > > > > > > int PortStatus; > > > > int value; > > > > int Relay1; > > > > }; > > > > > > > > Driver* > > > > drioDriver_Init (ConfigFile* cf, int section) > > > > { > > > > // Create and return a new instance of this driver > > > > return((Driver*)(new drioDriver (cf, section))); > > > > } > > > > void > > drioDriver_Register (DriverTable* table) > > > > { > > > > table->AddDriver("drioDriver", drioDriver_Init); > > > > } > > > > > > > > > > > > > > > > > > > > drioDriver::drioDriver (ConfigFile* cf, int section) > > > > : Driver(cf,section,true,PLAYER_MSGQUEUE_DEFAULT_MAXLEN) > > > > { > > > > // zero ids, so that we'll know later which interfaces were requested > > > > memset(&dio_id, 0, sizeof(dio_id)); > > > > // Do we create a dio interface? > > > > if(cf->ReadDeviceAddr(&dio_id, section, "provides", > > > > PLAYER_DIO_CODE, -1, NULL) == 0) > > > > { > > > > if(AddInterface(dio_id) != 0) > > > > { > > > > SetError(-1); > > > > return; > > > > } > > > > } > > > > serial_port = cf->ReadString(section,"port",DEFAULT_DRIODRIVER_PORT); > > > > port_rate = cf->ReadInt(section, "rate", DEFAULT_DRIODRIVER_PORT_RATE); > > > > } > > > > > > > > drioDriver:: ~drioDriver () > > > > { > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > int > > drioDriver::Setup() > > > > { > > > > // Open serial port > > > > this->fd = open (this->serial_port, O_RDWR); > > > > if (this->fd < 0) > > > > { > > > > PLAYER_ERROR2 ("> Connecting to drioDriver on [%s]; [%s]...[failed!]", > > > > (char*) this->serial_port, strerror (errno)); > > > > return (-1); > > > > } > > > > PLAYER_MSG0 (1, "> Connecting to drioDriver...[done]"); > > > > > > > > StartThread(); > > > > return (0); > > > > } > > > > > > > > int > > > > drioDriver::Shutdown() > > > > { > > > > > > > > // Stop the driver thread > > > > StopThread (); > > > > // Close the serial port > > > > tcsetattr (fd, TCSANOW, &initial_options); > > > > close (fd); > > > > PLAYER_MSG0 (1, "drioDriver shutting down... [done]"); > > > > return (0); > > > > } > > > > > > > > > > > > void > > drioDriver::Main() > > > > { > > > > for(;;) > > > > { > > > > pthread_testcancel(); > > > > memset(&data,0, sizeof(data)); > > > > Lock(); > > > > Unlock(); > > > > if (memcmp(&prev_data, &data, sizeof(data))) { > > > > PutData(); > > > > memcpy(&prev_data, &data, sizeof(data)); > > > > } > > > > // Handle pending messages > > > > if (InQueue->Empty() == false) { > > > > ProcessMessages(); > > > > } > > > > } > > > > usleep(100000); > > > > } > > > > > > > > int > > drioDriver::Subscribe(player_devaddr_t id) > > > > { > > > > return Driver::Subscribe(id); > > > > } > > > > int > > drioDriver::Unsubscribe(player_devaddr_t id) > > > > { > > > > return Driver::Unsubscribe(id); > > > > } > > > > > > > > void > > drioDriver::PutData() > > > > { > > > > PLAYER_MSG0(1, "Publishing dio data"); > > > > Publish(dio_id, NULL, PLAYER_MSGTYPE_DATA, > > > > PLAYER_DIO_DATA_VALUES, > > > > (void *) &data, sizeof(data)); > > > > } > > > > ///////////////////////////////////////////////////// > > > > // Message processing > > > > ///////////////////////////////////////////////////// > > > > int > > drioDriver::ProcessMessage(MessageQueue *queue, player_msghdr *hdr, void*data) > > > > { > > > > PLAYER_WARN("unknown message"); > > > > return -1; > > > > } > > > > > > > > > > > > /* Need the extern to avoid C++ name-mangling */ > > > > extern > > "C" { > > > > int > > player_driver_init(DriverTable* table) > > > > { > > > > PLAYER_MSG0(1, "Registering drioDriver driver."); > > > > drioDriver_Register(table); > > > > return 0; > > > > } > > > > } > > > > > > But when i go for compile by using g++. then the problem is like that. > > > > > > > > hoquea2@hoquea2-laptop:~/Desktop/box$ cd DRIVERhoquea2@hoquea2-laptop:~/Desktop/box/DRIVER$ > > g++ -o test `pkg-config --cflags playercore` drioDriver.cc `pkg-config > > --libs playercore` > > > > /usr/lib/gcc/i486-linux-gnu/4..1.2/../../../../lib/crt1.o: In function > > `_start': > > > > (.text+0x18): undefined reference to `main' > > > > collect2: ld returned 1 exit status > > > > hoquea2@hoquea2-laptop:~/Desktop/box/DRIVER$<hoquea2@hoquea2-laptop:%7E/Desktop/box/DRIVER$> > > > > > > > > my driver is ok or not if not please send me which portion i need to > > modify and whice way. > > > > > > best regards > > > > ASM Hoque > > > > PhD. student > > > > DCU > > > > Ireland > > > > > > ------------------------------ > > Get the freedom to save as many mails as you wish. Click here to know > > how.<http://in.rd.yahoo.com/tagline_mail_5/*http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/> > > > > > > -- > This email is intended for the addressee only and may contain privileged > and/or confidential information > > > ------------------------------ > Forgot the famous last words? Access your message archive online. Click > here.<http://in.rd.yahoo.com/tagline_webmessenger_4/*http://in.messenger.yahoo.com/webmessengerpromo.php> > -- This email is intended for the addressee only and may contain privileged and/or confidential information |