Example #1
0
/* PURPOSE: Opens a serial communications port
   INPUT:   The serial commpunications port name string
   OUTPUT:  Returns portstream handle if the serial port is successfully opened; 
            otherwise NULL */
portstream_fd openserial(char *portname)
{	 /* Serial communications parameters */
 	 int        speed    = serBaudRate;
	 int        parity   = NO_PARITY;
	 int        bits     = 8;
	 int        stopbits = 1;
	 portstream_fd pstream;

	 pstream = SetSerial(portname, speed, parity, bits, stopbits);

	 return pstream;
}
Example #2
0
int Rat::Init()
{
	if (SetMemoryPins())
	{
		SetSerial();
		SetPins();
		return 0;
	}
	else
	{
		return -1;
	}
}
Example #3
0
void CMessage::InitiaPack( int in_ComType, int in_ComNum )
{
	m_CmlCount = in_ComNum;
	m_Command  = in_ComType;
	SetDataLen(0);			 
	SetVersion(MSG_VER);	 
	SetSerial(0x00);		 
	SetCommand(m_Command);	 
	SetObligate(0);          
	SetCmlCount(m_CmlCount); 
	SetVerify(0);			 
	//留好参数长度空间
	SetComListLen( 0, m_CmlCount );
	//留好参数空间
	SetComCommandList(m_CmlCount);
}
Example #4
0
LRESULT CMFC_DEMOView::OnWTPacket(WPARAM wSerial, LPARAM hCtx)
{
	// Read the packet
	PACKET pkt;
	gpWTPacket( (HCTX)hCtx, wSerial, &pkt );

	// Process packets in order, one at a time
	CSingleLock lock( pWTMutex, TRUE );

	CDC *pDC = GetDC();
	
	// Get window size
	RECT window_rect;
	GetWindowRect( &window_rect );
	POINT size;
	size.x = window_rect.right - window_rect.left;
	size.y = window_rect.bottom - window_rect.top;

	// Erase the old cursor
	if( csr.x >= 0 ) {
		CRgn r;
		r.CreateRectRgn( csr.x - 2, csr.y - 2, csr.x + 2, csr.y + 2 );
		pDC->InvertRgn( &r );
	}

	csr.x = (size.x * pkt.pkX) / lc.lcInExtX;
	csr.y = size.y - (size.y * pkt.pkY) / lc.lcInExtY;

	if( pkt.pkButtons ) {
		
		CMFC_DEMODoc *pDoc = GetDocument();
		list<point> * lst = pDoc->GetLst();

		if( prev_pkButtons ) {
			
			list<point>::iterator i = lst->end();
			i--;
			pDC->MoveTo(abs(i->x),abs(i->y));

			lst->push_back(csr);
			pDC->LineTo(csr);


		/*********************  Write something below  ********************/

			
				new_time = clock();		//	some problems...
				
				SetSerial();

				
				int x = csr.x - DISPLAY_OFFSET_X;
				int y = csr.y - DISPLAY_OFFSET_Y;

				if(start == 1 && (double)(new_time - old_time) / CLOCKS_PER_SEC > 2) {
					WacomTrace("Time diff: %f\n", (double)(new_time - old_time) / CLOCKS_PER_SEC);
					start = 0;
					ConnectPoints();
					if((double)(new_time - old_time) / CLOCKS_PER_SEC > 4) {
						Output();
						Reset();
					} else {
						Set(x, y);
					}
				} else {
					if(start == 0 || (double)(new_time - old_time) / CLOCKS_PER_SEC > 0.15) {
					WacomTrace("Time diff: %f\n", (double)(new_time - old_time) / CLOCKS_PER_SEC);
						Set(x, y);
					}
					start = 1;
				}
				old_time = new_time;


				
		/*********************  Write something above  ********************/
			
		} else {
			
			POINT pt;
			pt.x = -csr.x;
			pt.y = -csr.y;
			lst->push_back(pt);
			

		}
		
	}

	prev_pkButtons = pkt.pkButtons;

	// Draw a new cursor
	CRgn r;
	r.CreateRectRgn( csr.x - 2, csr.y - 2, csr.x + 2, csr.y + 2 );
	pDC->InvertRgn( &r );

	ReleaseDC( pDC );

	return TRUE;
}