/*!
Default constructor.  Note that the name of the device used by a QextSerialPort constructed with
this constructor will be determined by #defined constants, or lack thereof - the default behavior
is the same as _TTY_LINUX_.  Possible naming conventions and their associated constants are:

\verbatim

Constant         Used By         Naming Convention
----------       -------------   ------------------------
Q_OS_WIN        Windows         COM1, COM2
_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
_TTY_OPENBSD_    OpenBSD         /dev/tty00, /dev/tty01
_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
<none>           Linux           /dev/ttyS0, /dev/ttyS1
\endverbatim

This constructor assigns the device name to the name of the first port on the specified system.
See the other constructors if you need to open a different port.
*/
QextSerialPort::QextSerialPort(QextSerialPort::QueryMode mode)
 : QIODevice()
{

#ifdef Q_OS_WIN
    setPortName("COM1");

#elif defined(_TTY_IRIX_)
    setPortName("/dev/ttyf1");

#elif defined(_TTY_HPUX_)
    setPortName("/dev/tty1p0");

#elif defined(_TTY_SUN_)
    setPortName("/dev/ttya");

#elif defined(_TTY_DIGITAL_)
    setPortName("/dev/tty01");

#elif defined(_TTY_FREEBSD_)
    setPortName("/dev/ttyd1");

#elif defined(_TTY_OPENBSD_)
    setPortName("/dev/tty00");

#else
    setPortName("/dev/ttyS0");
#endif

    construct();
    setQueryMode(mode);
    platformSpecificInit();
}
/*!
Constructs a serial port attached to the port specified by name.
name is the name of the device, which is windowsystem-specific,
e.g."COM1" or "/dev/ttyS0".
*/
QextSerialPort::QextSerialPort(const QString & name, QextSerialPort::QueryMode mode)
    : QIODevice()
{
    construct();
    setQueryMode(mode);
    setPortName(name);
    platformSpecificInit();
}
/*!
Constructs a port with default name and specified settings.
*/
QextSerialPort::QextSerialPort(const PortSettings& settings, QextSerialPort::QueryMode mode)
    : QIODevice()
{
    construct();
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setParity(settings.Parity);
    setStopBits(settings.StopBits);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Millisec);
    setQueryMode(mode);
    platformSpecificInit();
}
Exemple #4
0
QextSerialPortPrivate::QextSerialPortPrivate(QextSerialPort *q)
    :lock(QReadWriteLock::Recursive), q_ptr(q)
{
    lastErr = E_NO_ERROR;
    Settings.BaudRate = BAUD9600;
    Settings.Parity = PAR_NONE;
    Settings.FlowControl = FLOW_OFF;
    Settings.DataBits = DATA_8;
    Settings.StopBits = STOP_1;
    Settings.Timeout_Millisec = 10;
    settingsDirtyFlags = DFE_ALL;

    platformSpecificInit();
}
QextSerialEnumeratorPrivate::QextSerialEnumeratorPrivate(QextSerialEnumerator *enumrator)
    :q_ptr(enumrator)
{
    platformSpecificInit();
}
Exemple #6
0
/////////////////////////////////////////////////////////////////////////////
// init
/////////////////////////////////////////////////////////////////////////////
bool Vigasoco::init(std::string name)
{
	// calls template method to perform platform specific initialization
	if (!platformSpecificInit()){
		_errorMsg = "platformSpecificInit() failed";
		return false;
	}

	// creates the game driver
	_driver = createGameDriver(name);

	if (!_driver){
		_errorMsg = "unknown game " + name;
		return false;
	}

	// calls template method to create the palette
	createPalette();

	if (!_palette){
		_errorMsg = "createPalette() failed";
		return false;
	}

	// inits the palette (the last 2 colors are used by the core to display information)
	int numColors = _driver->getVideoInfo()->colors;

	// TODO: VGA 
	// Cambiar para no poner 256 a fuego
	_palette->init(256); // pruebas VGA
	

	// init the colors used by the core to display information
	/* 
	_palette->setColor(numColors + 0, 0x00, 0x00, 0x00);
	_palette->setColor(numColors + 1, 0xff, 0xff, 0xff);
	*/
	// TODO: VGA6, mientras probamos con VGA, metemos esto a fuego en el color 253 y 254
	_palette->setColor(253, 0x00, 0x00, 0x00);
	_palette->setColor(254, 0xff, 0xff, 0xff);


	// inits the fonts used by the core
	_fontManager = new FontManager(_palette, numColors/2);
	_fontManager->init();

	// creates the FileLoader
	FileLoader *fl = new FileLoader();

	// calls template method to add custom loaders
	addCustomLoaders(fl);

	// inits the game driver (load files, decode gfx, preprocessing, etc)
	if (!_driver->init(_palette)){
		// calls template method to remove custom loaders
		removeCustomLoaders(fl);

		delete fl;

		_errorMsg = "driver->init() failed\n" + _driver->getError();

		return false;
	}

	// calls template method to remove custom loaders
	removeCustomLoaders(fl);

	// deletes the FileLoader
	delete fl;

	// calls template method to get a DrawPlugin
	createDrawPlugin();

	if (!_drawPlugin){
		_errorMsg = "createDrawPlugin() failed";
		return false;
	}

	// inits the DrawPlugin with the selected GameDriver
	if (!_drawPlugin->init(_driver->getVideoInfo(), _palette)){
		_errorMsg = "drawPlugin->init() failed";
		return false;
	}
	// notify the driver that the drawPlugin has been initialized
	_driver->videoInitialized(_drawPlugin);

	// creates the input handler
	_inputHandler = new InputHandler();

	// calls template method to add input plugins
	addCustomInputPlugins();

	// inits the input handler
	if (!_inputHandler->init(_driver)){
		_errorMsg = "inputHandler->init() failed";
		return false;
	}

	// calls template method to get a high resolution timer
	createTimer();

	// creates the timing handler
	_timingHandler = new TimingHandler();

	// inits the timing handler
	if (!_timingHandler->init(_timer, _driver->getNumInterruptsPerSecond(), _driver->getNumInterruptsPerVideoUpdate(), _driver->getnumInterruptsPerLogicUpdate())){
		_errorMsg = "timerHandler->init() failed";
		return false;
	}

	// calls template method to get a AudioPlugin
	createAudioPlugin();

	if (!_audioPlugin){
		_errorMsg = "createAudioPlugin() failed";
		return false;
	}

	// inits the AudioPlugin with the selected GameDriver
	if (!_audioPlugin->init(/* TODO: _driver->getAudioInfo() */)){
		_errorMsg = "audioPlugin->init() failed";
		return false;
	}

	// notify the driver that the drawPlugin has been initialized
	_driver->audioInitialized(_audioPlugin);

	// creates the async thread
	createAsyncThread();

	if (!_asyncThread){
		_errorMsg = "createAsyncThread() failed";
		return false;
	}

	// calls template method to perform specific actions after initialization has been completed
	initCompleted();

	return true;
}