stm32+i

来自「STM32烧写」· 代码 · 共 68 行

TXT
68
字号
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
* File Name          : rs232.h
* Author             : MCD Application Team
* Version            : v2.0.0
* Date               : 03/07/2009
* Description        : Defines the CRS232 class for COM communication
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

#ifndef LSERIE_H
#define LSERIE_H

#include <string>
using namespace std;

#include "../COMBoxSDK/inc/UCEngine.h"

typedef enum CAN_STATUS  {STATUS_SUCCESS, STATUS_FAIL, STATUS_INFO, STATUS_INPUT, STATUS_UNDEFINED};

class CCAN  
{
public:
	
	FILE* log;
	TDataTree  ifcConfig;
	BOOL isConnected;
	long speedInBaud;
	int  timeout;

	//------ CONSTRUCTOR ------
	CCAN();									
	virtual ~CCAN();

	//------ OPEN AND CONFIGURE ------
	void SetComSettings(long _speedInBaud, int DLC);

	bool open();	//Open the serial port COM "numPort" at the speed "speedInBaud".
			  // bauds with and this adjustement : "nbBit" bit / "nbStopBit" stop bit / "parity").
														// Return: true if success.
	void closeCAN();			                //Close the serial port.
	bool setTimeOut(DWORD ms);					//Set the time-out for receive data. Return: true if success.
	bool setSpeed(DWORD baudrate);				//Set the speed in bauds. Return: true if success.
	bool setDefaultID(int did);				//Set the speed in bauds. Return: true if success.
	bool setFilterID(int fid);	

	void print_debug(char* messtype, char* mess, CAN_STATUS status);
	//------ SEND AND RECEIVE DATA ------
	int sendData(DWORD lg, LPBYTE data);		//Send table "data" of "lg" bytes.  Return: number of bytes really sent.
	int receiveData(DWORD lg, LPBYTE data);		//Receive table "data" who is limit at "lg" bytes.  Return: number of bytes received.
private:
	UCT_IFCHANDLE Handle;				//Otput file to the COM port    		| The file stream use for acces to the serial port.
	TDataTreeEntity *dataTreeentitydesc;

	_COMMTIMEOUTS	ct;                 //={0,0,0,0,0}; //Config du Time Out	| This variable contain the delay of the time-out. 
	DCB				dcb;				//Port configuration struct				| This object is use in order to configure the serial port.
	int				bufferSize;
};

#endif 

/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE******/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?