int main(int argc, const char *argv[]) { driver_return_code_t ret; driver_id_t driver_id = DRIVER_DEVICE; char *psz_drive = NULL; CdioDevice device; if (argc > 1) psz_drive = strdup(argv[1]); if (!psz_drive) { psz_drive = getDefaultDevice(driver_id); if (!psz_drive) { printf("Can't find a CD-ROM to perform eject operation\n"); exit(1); } } try { ejectMedia(psz_drive); printf("CD in CD-ROM drive %s ejected.\n", psz_drive); } catch ( DriverOpUninit e ) { printf("Can't Eject CD from CD-ROM drive: driver is not initialized.\n", psz_drive); } catch ( DriverOpException e ) { printf("Ejecting CD from CD-ROM drive %s operation error:\n\t%s.\n", psz_drive, e.get_msg()); } try { closeTray(psz_drive); printf("Closed CD-ROM %s tray.\n", psz_drive); } catch ( DriverOpException e ) { printf("Closing CD-ROM %s tray operation error error:\n\t%s.\n", psz_drive, e.get_msg()); } free(psz_drive); return 0; }
/*! Close media tray in CD drive if there is a routine to do so. @param psz_drive the name of CD-ROM to be closed. If omitted or NULL, we'll scan for a suitable CD-ROM. */ void closeTray (const char *psz_drive) { driver_id_t driver_id = DRIVER_UNKNOWN; closeTray(psz_drive, driver_id); }
void MountTray::programInit() { DCheck = new DevCheck(); //initialize class for checking devices qDebug() << "pc-mounttray: starting up"; MTINIT=true; //set the flag that the mount tray is initializing; //getInitialUsername(); //try to detect the non-root user who is running the program with root permissions getFileManager(); loadSavedSettings(); trayIcon = new QSystemTrayIcon(this); trayIconMenu = new QMenu(); //Generate the system menu options (these don't change) sysMenu = new QMenu( tr("More Options") ); sysMenu->setIcon( QIcon(":icons/config.png") ); //Add the additional options sysMenu->addAction( QIcon(":icons/folder.png"), tr("Open Media Directory"), this, SLOT(slotOpenMediaDir()) ); sysMenu->addAction( QIcon(":icons/harddrive.png"), tr("View Disk Usage"),this,SLOT(slotOpenFSDialog()) ); sysMenu->addAction( QIcon(":icons/refresh.png"),tr("Rescan Devices"), this, SLOT(slotRescan()) ); //Add the setting dialog option seperately sysMenu->addSeparator(); sysMenu->addAction( QIcon(":icons/dvd.png"), tr("Load ISO File"), this, SLOT(slotOpenISO()) ); sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) ); //Add the Close button seperately sysMenu->addSeparator(); sysMenu->addAction( QIcon(":icons/application-exit.png"), tr("Close Tray"), this, SLOT(closeTray()) ); // Tie the left-click signal to open the context menu connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason)) ); //Connect the message clicked slot connect(trayIcon,SIGNAL(messageClicked()),this,SLOT(slotPopupClicked()) ); //Set the default Tray Icon (will change once tray menus are set) trayIcon->setIcon(QIcon(":icons/CDdevices-inactive.png")); trayIcon->show(); //Do an initial scan of the devices with dmesg qDebug() << "-Performing initial device scan"; scanInitialDevices(); //Startup the devd watching process qDebug() << "-Starting up the DEVD watcher"; devdTimer = new QTimer(); devdTimer->setSingleShot(TRUE); connect(devdTimer,SIGNAL(timeout()),this,SLOT(slotDevChanges())); startupDevdProc(); //Start up the filesystem watcher diskWatcher = new FSWatcher(); connect(diskWatcher,SIGNAL(FSWarning(QString,QString)),this,SLOT(slotDisplayWarning(QString,QString))); if(useDiskWatcher){ qDebug() << "-Starting up the disk space alert system"; diskWatcher->start(diskTimerMaxMS); } //Update the tray menu and icons updateMenu(); qDebug() << "-Program now ready for use"; QTimer::singleShot(500, this, SLOT(slotDoneWithInit()) ); //give it 1/2 a second to settle }
int main() { trayOpen = 0; raspi.baud(921600); cuvettePeltCycle(); wait(10); // raspi.printf("meridianScientific_ramanSpectrometer_controlBoard_V0\r\n"); while (!device.initialize()); // keep calling until it works int deviceCount = device.getDeviceCount(); // raspi.printf("Located %d sensors\n\r",deviceCount); z = 0; device.setResolution(twelveBit); while(1) { // for (int i = 0; i < deviceCount; i++) { // readTemp(i); // } if (raspi.readable()) { // check if serial port is reaadable switch (raspi.getc()) { // retrieve a character from serial case packet_start: // case for packet start flag switch (raspi.getc()) { // set condition for listening to another character case packet_flag: // case for packet flag packetFlag = 1; // turn the flag on while (packetFlag == 1) { // start a loop that runs while the flag is on switch (raspi.getc()) { // set another condition for listening to another character case cmd_laser: // case for cmd_laser grnLED = 1; // turn the led on raspi.printf("%x", cmd_laser); // return cmd_laser to the raspi switch (raspi.getc()) { // set another condition for listening to another character case req_laser_temp: // case for req_laser_temp raspi.printf("%x\r\n", req_laser_temp); // return req_laser_temp to the raspi readTemp(0); // read the temperature for device 0 which is the laser temp sensor grnLED = 0; // turn led off continue; // continue through loop default: // default if nothing matches break; // break from loop } case cmd_cuvette: // case for cmd_cuvette grnLED = 1; // turn led on raspi.printf("%x", cmd_cuvette); // return cmd_cuvette to raspi switch (raspi.getc()) { // set condition for listening to another character case req_cuvette_temp: // case for req_cuvette_temp raspi.printf("%x\r\n", req_cuvette_temp); // return req_cuvette_temp to raspi readTemp(1); // read the temperature for device 1 which is the cuvette temp sensor grnLED = 0; // turn the led off continue; // continue through the loop case tray_open: // case for tray_open raspi.printf("%x\r\n", tray_open); // return tray_open to raspi if (trayOpen == 0) { // check to see if the tray is closed openTray(); // if not, open tray } else { // otherwise raspi.printf("%x\r\n", cuvette_err); // send a cuvette error to the raspi } grnLED = 0; // turn led off continue; // continue through the loop case tray_close: // case for tray close raspi.printf("%x\r\n", tray_close); // return tray_close to raspi if (trayOpen == 1) { // check to see if tray is open closeTray(); // if not, close tray } else { // otherwise raspi.printf("%x\r\n", cuvette_err); // send a cuvette error to the raspi } grnLED = 0; // turn led off continue; // continue through loop default: // default if nothing matches break; // break from loop } case cmd_filter_wheel: // case for cmd_filter_wheel grnLED = 1; // turn led on raspi.printf("%x", cmd_filter_wheel); // return cmd_filter_wheel to raspi switch (raspi.getc()) { // set condidition for listening to another character case filter_select: // case for filter_select raspi.printf("%x\r\n", filter_select); // return filter_select to raspi filterForward(); // move filter wheel forward one filter filterBack(); // move filter wheel reverse one filter (this is just to test the commands) grnLED = 0; // turn led off continue; // continue through loop default: // default if nothing matches break; // break from loop } case cmd_cuvette_peltier: grnLED = 1; // turn led on raspi.printf("%x", cmd_cuvette_peltier); // return cmd_ccd_peltier to raspi switch (raspi.getc()) { // set condidition for listening to another character case cmd_cuvette_pelt_power: switch (raspi.getc()) { // set condidition for listening to another character case 0x00: // case for cmd_ccd_peltier OFF raspi.printf("%x\r\n", cmd_cuvette_pelt_power); // return filter_select to raspi cuvettePeltA = 0; // set PWM A to zero cuvettePeltB = 0; // set PWM B to zero grnLED = 0; // turn led off break; case 0x01: // case for cmd_cuvette_peltier COOL raspi.printf("%x\r\n", cmd_cuvette_pelt_power); // return filter_select to raspi cuvettePeltA = 0.5; // set PWM A to 0.5 cuvettePeltB = 0; // set PWM B to zero grnLED = 0; // turn led off break; case 0x02: // case for cmd_cuvette_peltier HEAT raspi.printf("%x\r\n", cmd_cuvette_pelt_power); // return filter_select to raspi cuvettePeltA = 0; // set PWM A to 0.5 cuvettePeltB = 0.5; // set PWM B to zero grnLED = 0; // turn led off break; default: break; } continue; default: break; } case cmd_ccd_peltier: grnLED = 1; // turn led on raspi.printf("%x", cmd_ccd_peltier); // return cmd_ccd_peltier to raspi switch (raspi.getc()) { // set condidition for listening to another character case cmd_ccd_pelt_power: switch (raspi.getc()) { // set condidition for listening to another character case 0x00: // case for cmd_ccd_peltier OFF raspi.printf("%x\r\n", cmd_ccd_pelt_power); // return filter_select to raspi ccdPeltA = 0; // set PWM A to zero ccdPeltB = 0; // set PWM B to zero grnLED = 0; // turn led off break; case 0x01: // case for cmd_ccd_peltier COOL raspi.printf("%x\r\n", cmd_ccd_pelt_power); // return filter_select to raspi ccdPeltA = 0.5; // set PWM A to 0.5 ccdPeltB = 0; // set PWM B to zero grnLED = 0; // turn led off break; case 0x02: // case for cmd_ccd_peltier HEAT raspi.printf("%x\r\n", cmd_ccd_pelt_power); // return filter_select to raspi ccdPeltA = 0; // set PWM A to 0.5 ccdPeltB = 0.5; // set PWM B to zero grnLED = 0; // turn led off break; default: break; } continue; default: break; } case packet_end: // case for packed_end packetFlag = 0; // set the packetFlag to 0 break; // break from loop default: // default if nothing matches break; // break from loop } } default: // defailt if nothing matches break; // break from loop } default: // default if nothing matches break; // break from loop } } } }