Exemple #1
0
int At250xx::Read(int probe, int type)
{
    UserDebug1(UserApp1, "At250xx::Read(%d)\n", probe);

    if (probe || GetNoOfBank() == 0)
        Probe();

    int size = GetNoOfBank() * GetBankSize();

    UserDebug1(UserApp1, "At250xx::Read() ** Size = %d\n", size);

    int rv = size;
    if (type & PROG_TYPE)
    {
        rv = GetBus()->Read(0, GetBufPtr(), size);
        if (rv != size)
        {
            if (rv > 0)
                rv = OP_ABORTED;
        }
    }

    UserDebug1(UserApp1, "At250xx::Read() = %d\n", rv);

    return rv;
}
//=====================>>> cubeApp::AppCommand <<<==============================
  void cubeApp::AppCommand(vWindow* win, ItemVal id, ItemVal val, CmdType cType)
  {
    // Commands not processed by the window will be passed here

    UserDebug1(Build,"cubeApp::AppCmd(ID: %d)\n",id);
    vApp::AppCommand(win, id, val, cType);
  }
Exemple #3
0
int LPTIOInterface::OutControlPort(int val, int port_no)
{
	UserDebug2(UserApp3, "LPTIOInterface::OutControlPort(%d, %d)\n", val, port_no);

	int ret_val = OK;

	if ( port_no >= 1 && port_no <= MAX_LPTPORTS &&
			port_no != lpt_port )
	{
		lpt_port = port_no;

		PortInterface::CloseParallel();
		ret_val = PortInterface::OpenParallel(lpt_port);
	}

	if (ret_val == OK)
	{
		last_ctrl = val;
		ret_val = PortInterface::OutPort(val, ctrlOfst);
	}

	UserDebug1(UserApp3, "LPTIOInterface::OutControlPort() = %d\n", ret_val);

	return ret_val;
}
//=====================>>> vgApp::NewAppWin <<<==========================
  vWindow* vgApp::NewAppWin(vWindow* win, VCONST char* name, 
    int w, int h, vAppWinInfo* winInfo)
  {
    vAppWinInfo* awinfo = winInfo;
    VCONST char *vgname = name;

    if (!*name)
      {
        vgname = "V Shell App Generator";               // Default name
      }
        
    UserDebug1(Build,"vgApp::NewAppWin(%s)\n",vgname);

    // Create the first window using provided CmdWindow

    _vgCmdWin = (vgCmdWindow*) win;
    if (!_vgCmdWin)
      {
        _vgCmdWin = new vgCmdWindow(vgname, w, h);
      }

    if (!awinfo)
        awinfo = new vAppWinInfo(vgname);

    return vApp::NewAppWin(_vgCmdWin, vgname, w, h, awinfo);
  }
//=====================>>> cubeApp::NewAppWin <<<==========================
  vWindow* cubeApp::NewAppWin(vWindow* win, char* name,
    int w, int h, vAppWinInfo* winInfo)
  {
    vAppWinInfo* awinfo = winInfo;
    char *appname = name;

    if (!*name)
      {
	 appname = "V/OpenGL Demo - Cube";		// Default name
      }
	
    UserDebug1(Build,"cubeApp::NewAppWin(%s)\n",appname);

    // Create the first window using provided CmdWindow

    _cubeCmdWin = (cubeCmdWindow*) win;
    if (!_cubeCmdWin)
      {
	_cubeCmdWin = new cubeCmdWindow(appname, w, h);
      }

    if (!awinfo)
	awinfo = new vAppWinInfo(appname);

    return vApp::NewAppWin(_cubeCmdWin, appname, w, h, awinfo);
  }
Exemple #6
0
void SPIBus::SetDelay()
{
	int val = THEAPP->GetSPISpeed();
	int n;

	switch(val)
	{
	case TURBO:
		n = 0;         // as fast as your PC can
		break;
	case FAST:
		n = 1;
		break;
	case SLOW:
		n = 10;
		break;
	case VERYSLOW:
		n = 80;
		break;
	case ULTRASLOW:
		n = 1000;
		break;
	default:
		n = 5;         //Default (< 100KHz)
		break;
	}
	BusIO::SetDelay(n);

	UserDebug1(UserApp2, "SPIBus::SetDelay() = %d\n", n);
}
//=====================>>> tutApp::AppCommand <<<=========================
  void tutApp::AppCommand(vWindow* win, ItemVal id, ItemVal val,
    CmdType cType)
  {
    // Any commands not processed by the window WindowCommand
    // method will be passed to here for default treatment.

    UserDebug1(Build,"tutApp::AppCmd(ID: %d)\n",id);
    vApp::AppCommand(win, id, val, cType);
  }
Exemple #8
0
int e2Dialog::DialogAction(char *msg)
{
	UserDebug1(UserApp1, "e2Dialog::DialogAction() IN *** M_Cancel=%d\n", M_Cancel);

	SetCommandObject(chkPol1, (THEAPP->GetPolarity() & RESETINV) ? 1 : 0, DefaultCmds);
	SetCommandObject(chkPol2, (THEAPP->GetPolarity() & CLOCKINV) ? 1 : 0, DefaultCmds);
	SetCommandObject(chkPol3, (THEAPP->GetPolarity() & DININV) ? 1 : 0, DefaultCmds);
	SetCommandObject(chkPol4, (THEAPP->GetPolarity() & DOUTINV) ? 1 : 0, DefaultCmds);

	AddDialogCmds(DefaultCmds);		// add the predefined commands

	ItemVal ans, rval;
	ans = ShowModalDialog(msg, rval);
	if (ans == M_Cancel)
		return 0;

	// *** Add code to process dialog values here
	if (GetValue(chkPol1))
		THEAPP->SetPolarity(THEAPP->GetPolarity() | (UBYTE)RESETINV);
	else
		THEAPP->SetPolarity(THEAPP->GetPolarity() & (UBYTE)~RESETINV);

	if (GetValue(chkPol2))
		THEAPP->SetPolarity(THEAPP->GetPolarity() | (UBYTE)CLOCKINV);
	else
		THEAPP->SetPolarity(THEAPP->GetPolarity() & (UBYTE)~CLOCKINV);

	if (GetValue(chkPol3))
		THEAPP->SetPolarity(THEAPP->GetPolarity() | (UBYTE)DININV);
	else
		THEAPP->SetPolarity(THEAPP->GetPolarity() & (UBYTE)~DININV);

	if (GetValue(chkPol4))
		THEAPP->SetPolarity(THEAPP->GetPolarity() | (UBYTE)DOUTINV);
	else
		THEAPP->SetPolarity(THEAPP->GetPolarity() & (UBYTE)~DOUTINV);

	bool set_port = false;
	if (port_no != THEAPP->GetPort())
		set_port = true;
	if (interf_type != THEAPP->GetInterfaceType())
	{
		THEAPP->ClosePort();
		THEAPP->SetInterfaceType(interf_type);
		set_port = true;
	}
	if (set_port)
		THEAPP->SetPort(port_no);

	//Store values in the INI file
	THEAPP->SetParInterfType(interf_type);
	THEAPP->SetParPortNo(port_no);
	THEAPP->SetPolarityControl(THEAPP->GetPolarity());

	return ans == M_OK;
}
Exemple #9
0
// determina il numero di banchi (dimensione) dell'eeprom
//---
int At250xx::Probe(int probe_size)
{
    UserDebug1(UserApp1, "At250xx::Probe(%d)\n", probe_size);

//	if (probe_size)
//	{
//		SetNoOfBank(n_bank);
//	}

    return OK;
}
Exemple #10
0
void LPTIOInterface::SetPort(int port_no)
{
	UserDebug1(UserApp2, "LPTIOInterface::SetPort(%d)\n", port_no);

	if ( port_no >= 1 && port_no <= MAX_LPTPORTS ) 
	{
		lpt_port = port_no;

		PortInterface::CloseParallel();
		PortInterface::OpenParallel(lpt_port);
	}
}
Exemple #11
0
void e2ProgressDialog::UpdateDialog(int val, char *msg)
{
	pbr_value = val;
	SetValue(pbrProgress,val,Value);    // The horizontal bar
	if (msg)
	{
		UserDebug(UserApp2,"e2ProgressDialog::UpdateDialog() closing...\n")

		CloseDialog();

		UserDebug1(UserApp2,"e2ProgressDialog::UpdateDialog() showing... (%s)\n", msg)

		ShowDialog(msg);
	}
}
//=========================>>> tutApp::NewAppWin <<<======================
  vWindow* tutApp::NewAppWin(vWindow* win, VCONST char* name, int w, int h,
    vAppWinInfo* winInfo)
  {
    // This version of NewAppWin is provided with the information
    // required to name and size a window. You can derive
    // 
    // Typically, this method would get a file name or other information
    // needed to setup the AppWinInfo class  specifically for the
    // application. Thus, each open window usually represents a view of
    // a file or data object.

    vWindow* thisWin = win;             // local copy to use
    vAppWinInfo* awinfo = winInfo;
    VCONST char *myname = name;                // local copy

    if (!name || !*name)
        myname = "Example";            // make up a name
        
    // The UserDebug macros are useful for tracking what is going on.
    // This shows we're building a window.

    UserDebug1(Build,"tutApp::NewAppWin(%s)\n",myname);

    // You may instantiate an instance of the window outside of
    // NewAppWin, or allow NewAppWin to create the instance.

    if (!thisWin)       // Didn't provide a window, so create one.
        thisWin = new tCmdWindow(myname, w, h);

    // The vAppWinInfo class is meant to serve as a database used by the
    // tutApp controller. If you use this feature, you will probably
    // derive your own myAppWinInfo class from vAppWinInfo. The instance
    // of vAppWinInfo created here will be automatically deleted when
    // this window instance is closed through CloseAppWin.

    if (!awinfo)        // Did caller provide an appinfo?
        awinfo = new vAppWinInfo(myname);

    // After you have created an instance of the window and an instance
    // of the AppWinInfo, you MUST call the base vApp::NewAppWin method.
    // You won't need to explicitly keep track of the pointer to
    // each new window -- unless it has to interact with other windows.
    // If that is the case, then you can use your derived vAppWinInfo
    // to coordinate the interaction.

    return vApp::NewAppWin(thisWin,name,w,h,awinfo);
  }
//====================>>> testCmdWindow::testCmdWindow <<<====================
  testCmdWindow::testCmdWindow(char* name, int height, int width) :
    vCmdWindow(name, height, width)
  {
    UserDebug1(Constructor,"testCmdWindow::testCmdWindow(%s) Constructor\n",name)

    // The Menu Bar
    testMenu = new vMenuPane(StandardMenu);
    AddPane(testMenu);

    // The Canvas
    testCanvas = new testCanvasPane;
    AddPane(testCanvas);


    // Show Window

    ShowWindow();
    testCanvas->ShowVScroll(1);	// Show Vert Scroll
    testCanvas->ShowHScroll(1);	// Show Horiz Scroll
  }
Exemple #14
0
int LPTIOInterface::InDataPort(int port_no)
{
	UserDebug2(UserApp3, "LPTIOInterface::InDataPort(%d) ** lp=%d\n", port_no, lpt_port);

	int ret_val = OK;

	if ( port_no >= 1 && port_no <= MAX_LPTPORTS &&
			port_no != lpt_port )
	{
		lpt_port = port_no;

		PortInterface::CloseParallel();
		ret_val = PortInterface::OpenParallel(lpt_port);
	}

	if (ret_val == OK)
		ret_val = PortInterface::InPort(statOfst);

	UserDebug1(UserApp3, "LPTIOInterface::InDataPort() = %d\n", ret_val);

	return ret_val;
}
Exemple #15
0
int e2Dialog::Test(int p, int open_only) const
{
	UserDebug2(UserApp1, "e2Dialog::Test() IN *** p=%d, open_only=%d\n", p, open_only);

	HInterfaceType old_interf = THEAPP->GetInterfaceType();
	int test;

	if (p == 0)
		p = port_no;

	if (interf_type != old_interf)
	{
		THEAPP->SetInterfaceType(interf_type);
		test = THEAPP->TestPort(p, open_only);
		THEAPP->SetInterfaceType(old_interf);
	}
	else
		test = THEAPP->TestPort(p, open_only);

	UserDebug1(UserApp1, "e2Dialog::Test() = %d *** OUT\n", test);

	return test;
}
Exemple #16
0
int RS232Interface::OpenSerial(int no)
{
	UserDebug1(UserApp1, "RS232Interface::OpenSerial(%d) I\n", no);

	int ret_val = E2ERR_OPENFAILED;

	if (no >= 1 && no <= MAX_COMPORTS)
	{
#ifdef	_WINDOWS
		char str[MAXPATH];

		snprintf(str, MAXPATH, "%s%d", profile->GetDevName(), no);
		hCom = CreateFile(str,
			GENERIC_READ | GENERIC_WRITE,
			0,		/* comm devices must be opened w/exclusive-access */
			NULL,	/* no security attrs */
			OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
			0,		/* not overlapped I/O */
			NULL	/* hTemplate must be NULL for comm devices */
		);

		if ( hCom != INVALID_HANDLE_VALUE )
		{
			GetCommState(hCom, &old_dcb);
			GetCommTimeouts(hCom, &old_timeout);
			GetCommMask(hCom, &old_mask);

			if (wait_endTX_mode)
				SetCommMask(hCom, EV_TXEMPTY);
			else
				SetCommMask(hCom, 0);

			SetSerialTimeouts();
			SetSerialParams();

			ret_val = OK;
		}
#else
#ifdef	_LINUX_

		char devname[MAXPATH];
		int chars_read;

		no--;		//linux call ttyS0 --> COM1, ttyS1 --> COM2, etc..

		// implement device locking in /var/lock/LCK..ttySx
		snprintf(lockname, MAXPATH, "%s/LCK..%s%d", profile->GetLockDir(), profile->GetDevName(), no);
		UserDebug1(UserApp2, "RS232Interface::OpenSerial() now lock the device %s\n", lockname);

		fd = open ((const char *)lockname,O_RDWR|O_EXCL|O_CREAT);
		if (fd < 0)
		{
			fd = open ((const char *)lockname,O_RDONLY);
			lockname[0]=0;
			UserDebug1(UserApp2, "RS232Interface::OpenSerial Can't lock port %d\n", no);
			if (fd < 0)
				return ret_val;
			chars_read = read(fd,devname,MAXLINESIZE-1);
			devname[chars_read]=0;
			UserDebug1(UserApp2, "RS232Interface::OpenSeriial locked by %s\n", devname);
			close(fd);
			return ret_val;
		}

		snprintf(devname, MAXPATH, "%10d\n", (int) getpid() );
		write(fd, devname, strlen(devname));
		close(fd);
		fd = INVALID_HANDLE_VALUE;

		snprintf(devname, MAXPATH, "%s/%s%d", profile->GetDevDir(), profile->GetDevName(), no);
		UserDebug1(UserApp2, "RS232Interface::OpenSerial() now open the device %s\n", devname);

		fd = open ((const char *)devname, O_RDWR|O_NONBLOCK|O_EXCL);
	//	fd = open ((const char *)devname, O_RDWR);

		UserDebug1(UserApp2, "RS232Interface::OpenSerial open result = %d\n", fd);

		if (fd < 0)
		{
			UserDebug1(UserApp2, "RS232Interface::OpenSerial can't open the device %s\n", devname);
			unlink(lockname);
			return ret_val;
		}
		// Check for the needed IOCTLS
#if defined(TIOCSBRK) && defined(TIOCCBRK) //check if available for compilation
		// Check if available during runtime
		if ((ioctl(fd,TIOCSBRK,0) == -1) || (ioctl(fd,TIOCCBRK,0) == -1))
		{
			UserDebug(UserApp2, "RS232Interface::OpenPort IOCTL not available\n");
			return ret_val;
		}
#else
		close(fd);
		fd = INVALID_HANDLE_VALUE;
		unlink(lockname);
		return ret_val;
#endif	/*TIOCSBRK*/

		/* open sets RTS and DTR, reset it */
#if defined(TIOCMGET) && defined(TIOCMSET) //check if available for compilation
		int flags;

		if (ioctl(fd,TIOCMGET, &flags)== -1)
		{
			UserDebug(UserApp2, "RS232Interface::OpenPort IOCTL not available\n");
			close(fd);
			fd = INVALID_HANDLE_VALUE;
			unlink(lockname);
			return ret_val;
		}
		else
		{
			flags &= ~(TIOCM_RTS|TIOCM_DTR);
			if (ioctl(fd,TIOCMSET, &flags)== -1)
			{
				UserDebug(UserApp2, "RS232Interface::OpenPort IOCTL not available\n");
				close(fd);
				fd = INVALID_HANDLE_VALUE;
				unlink(lockname);
				return ret_val;
			}
		}
#endif /*TIOCMGET */

		UserDebug(UserApp2, "RS232Interface::OpenPort GETATTR\n");
		if (tcgetattr(fd, &old_termios) == -1)
		{
			UserDebug(UserApp2, "RS232Interface::OpenPort GETATTR failed\n");

			close(fd);
			fd = INVALID_HANDLE_VALUE;
			unlink(lockname);
			return ret_val;
		}

		UserDebug(UserApp2, "RS232Interface::OpenPort SetTimeouts && Params\n");
		if ( SetSerialTimeouts() != OK )
		{
			UserDebug(UserApp2, "RS232Interface::OpenPort SetSerialTimeouts() failed\n");
			close(fd);
			fd = INVALID_HANDLE_VALUE;
			unlink(lockname);
		}
		else
		if ( SetSerialParams() != OK )
		{
			UserDebug(UserApp2, "RS232Interface::OpenPort SetSerialParams() failed\n");
			close(fd);
			fd = INVALID_HANDLE_VALUE;
			unlink(lockname);
		}
		else
		{
			fd_clear_flag(fd, O_NONBLOCK);		//Restore to blocking mode
			ret_val = OK;
		}

#endif	/*_LINUX_*/
#endif
	}

	UserDebug1(UserApp2, "RS232Interface::OpenSerial() = %d O\n", ret_val);

	return ret_val;
}