亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? mslp35xx.c

?? modbus 運(yùn)用事例
?? C
字號(hào):
/********* Sample Program ****************************************************


MSLP35xx.c	Copyright(c) 2003 Z-World Engineering.
					
Legal Notice	This program has been written by the Technical Support Staff at 
					Z-World in response to several customer requests.  As such, it 
					has NOT had the testing and validation procedures which our 
					"standard" software products have.  It is being made available 
					as a sample.  There is no warranty, implied or otherwise. 

DESCRIPTION:	Sample program demonstrating modbus slave control via RS485
					for the LP35xx SBC's (serial port F).
				
					This sample will allow control via a Modbus Master controller
					of the following;
					
					1. Read from/Write to  digital outputs
					2.	Read the status of digital inputs 
					3. Read the Analog inputs (Cal. Data).

MODBUS
COMMAND 
FUNCTIONS
USED:				
					01:	Discrete Coil Status
					01:	Discrete Coil Writing
					02:	Discrete Input Status
					03:	Holding Register Status
					03:	Holding Register Writing
					04:	Input Register Status
					 
					The modbus master software used with this sample can be 
					downloaded (Demo Version) via the following company link.
					
					WinTECH Software Systems incorporated
					
					http://www.win-tech.com
					(modscan32.exe)
					
NOTES:			This sample does show 1 technique on how to convert float
					values (in this case the analog channel values), to unsigned
					int register pairs for use with the Modbus master.
					          

*****************************************************************************/

/******   Start of user configurable macros *********************************/

// Define the number of channels for each type of input

// Number of analog inputs.
#define	ADC_AMOUNT			8
#define	ADC_GAINCODE		0



// Number of digitial I/O
#define	INPUT_AMOUNT		16
#define	OUTPUT_AMOUNT		10

// Provide an ID for the slave device.  It MUST BE UNIQUE from any other 
// Modbus device connected. (Address 0 is the Master device).
#define	SLAVE_ADDRESS		0x01

// The baudrate used for the MODBUS protocol.
#define	MODBUS_BAUDRATE	9600	// 9600 is default, 19200 works to.

// Choose the protocol type, 0 for ASCII, 1 for RTU.  This MUST match the
// Modbus master protocol selection.
#define	MODBUS_TYPE			1	

/******  Done with user configurable macros *********************************/

// Setup up the serial port buffer size
#define	FINBUFSIZE	31
#define	FOUTBUFSIZE	31

// Modbus slave library, it also calls ms_rab.lib
#use		"msz_rab.lib"

//	Digital Output Shadow Registers
char 		acShad[OUTPUT_AMOUNT + 1];
//	Analog Output Shadow Registers

/************************ MODBUS FUNCTIONS *********************************\

The following are the individual Modbus functions.  The function Names must
stay the same for they are used in the ms_rab.lib.  The content of the
function will change for each application.  The following functions are
required to be in you application;

msDone, msStart, and msRun  

msXinit, msXrx, msXtx (X = A,B,C,D,E or F for the serial port you are using).


/***************************************************************************/

/*=========================================================================*\
msDone:

	Called just after a received Modbus command has been
	processed and just before the reply is sent. This function is intended
	to be used to unlock resources that were locked by msStart(). Locking
	resources may or may not be required, depending on how the msIn(),
	msInput(), msOutRd() and msOutWr() functions are implemented in a
	particular Modbus slave application. Note that Modbus command handler
	functions in MS_RAB.LIB may make multiple calls to those functions while
	responding to a single Modbus command.
	
\*=========================================================================*/
		
nodebug
void msDone(void)
{
	// place any locked resources required.
	 
}

/*=========================================================================*\
msStart:

	Called just before a received Modbus packet is processed,
	this function is primarily intended to be used to lock resources so
	that data returned in one Modbus response packet are atomic. Locking
	resources may or may not be required, depending on how the msIn(),
	msInput(), msOutRd() and msOutWr() functions are implemented in a
	particular Modbus slave application. Note that Modbus command handler
	functions in MS_RAB.LIB may make multiple calls to those functions while
	responding to a single Modbus command.

\*=========================================================================*/

nodebug
void msStart(void)
{
	// place any locked resources required.
	
}


/*=========================================================================*\
msDinit:
	Sets up and opens the serial port.  default settings are 8 data bits
	1 stop bit, no parity, no flow control.  You can change the settings 
	to match the Modbus serial control of your system.

\*=========================================================================*/

int msFinit(unsigned qBaud)
{
	// Open the serial port.  THIS MUST BE DONE PRIOR TO SETTING THE
	// DATA BITS AND PARITY SETTINGS.
	serFopen(qBaud); 
	  
	// setup parity.  Either PARAM_OPARITY, PARAM_EPARITY, PARAM_NOPARITY, 
	// or PARAM_2STOP  
	serFparity(PARAM_NOPARITY);
	 
	// setup data bits. Either PARAM_7BIT, or PARAM_8BIT  
	serFdatabits(PARAM_8BIT);
	
  	// Set the Serial port mode. Used for Zworld SBC's only.  
	serMode(0);  
	return(1);
}

/*=========================================================================*\
msDtx:
	User definable function for enabling the rs485 transmitter (if needed).
	If you are doing RS232 simply leave the function blank.  The function
	itself must be present.

\*=========================================================================*/

void msFtx()
{
	// Turn on the transmitter. 
	ser485Tx();
}

/*=========================================================================*\
msDrx:
	User definable function for disabling the rs485 transmitter (if needed).
	If you are doing RS232 simply leave the function blank. The function  
	itself must be present.

\*=========================================================================*/

void msFrx()
{	
	// Make sure all of the data has been sent by;
	// 1.) checking the write buffer for any bytes left
	// 2.) checking the status of the Write interrupt transmit bit (2).
	// 3.) checking the status of the Write interrupt data bit (3)
	while (serFwrUsed() || BitRdPortI(SFSR,2) || BitRdPortI(SFSR,3)); 
	// turn off the transmitter
	ser485Rx();
	// Since we echo what we send, flush the read buffer, so that you are
	// ready for the next packet.
	serFrdFlush();	 
}

/*=========================================================================*\
	msOutRd:	(01:   Discrete Coil Status)
	
		Used for reading output coil status.  A user defined shadow register
		is required in your code which will  be updated when digital
		outputs change states using the msOutWr function.
		
		registers used;    
			0x00001 -> 	0x00016 	Digital Output 0 -> Digital Output 9    
		    
\*=========================================================================*/

int msOutRd(unsigned wCoil, int *pnState)
{
	//  Check to see if a valid output channel is being called.
	if (wCoil > (OUTPUT_AMOUNT) )	return MS_BADADDR;
	// copy the contents of the coil shadow element.
	*pnState = acShad[wCoil];
	return 0;
}

/*=========================================================================*\
	msOutWr:	(01:  Discrete Coil Writing)  
		Used for Writing to individual output coils, as well as updating
		the shadow register used in the above function msOutRd. 
		 
		registers used;
			0x00001 -> 	0x00016 (Digital Output 0 -> Digital Output 9)    
		 
\*=========================================================================*/

int msOutWr(unsigned wCoil, int bState)
{
	//  Check to see if a valid output channel is being called.  
	if ( wCoil > (OUTPUT_AMOUNT) )	return MS_BADADDR;
	//  update the shadow used in the msOutRd function.
	acShad[wCoil] = bState;
	// Update the digital outpu;
	digOut(wCoil,bState);
	return 0;
}

/*=========================================================================*\
	msIn:	(02:	Discrete Input Status)
		Used for reading the state of the individual digital inputs.
		
	  registers used;	   
	 		0x10001 -> 	0x10024 (Digital Input 0 -> Digital Input 15) 
	 			   
\*=========================================================================*/

int msIn(unsigned wCoil, int *pnState)
{
	//  Check to see if a valid input channel is being called.    
	if (wCoil > INPUT_AMOUNT)	return MS_BADADDR;
	//  Read the input and store it.
	*pnState = digIn(wCoil);
	return 0;
}

/*=========================================================================*\
	msInput:	(04:	Reading from a Input Register)  
		   
		Setup to read the individual CALIBRATED values of each adc inputs.
		Since Modbus deals with unsigned ints (words), and our VDC input
		function returns a float, the function will need to store the value
		as two registers type casted into unsigned ints for the Modbus 
		protocol to accept properly.  How this is done must be the same for
		both the Master and the slave.  This example shows one way to 
		accomplish that.  The Master must use the same method for decoding
		the two unsigned ints and convert it back to a float.  A sample of
		this is the msWrite function that converts 2 unsigned ints into a
		float for use with the DAC outputs.
		
		registers used;
		  	0x30001 -> 0x30002 = Float val of ADC 0    
			0x30003 -> 0x30004 = Float val of ADC 1  
			0x30005 -> 0x30006 = Float val of ADC 2  
			0x30007 -> 0x30008 = Float val of ADC 3  
			0x30009 -> 0x30010 = Float val of ADC 4    
			0x30011 -> 0x30012 = Float val of ADC 5  
			0x30013 -> 0x30014 = Float val of ADC 6  
			0x30015 -> 0x30016 = Float val of ADC 7  

\*=========================================================================*/

int msInput(unsigned wReg, unsigned *pwValue)
{
	static float calVal;
	static unsigned int  uiVal[2];
	// Since it will take two registers per input, you must double the 
	// amount of register neccessary.
	if (wReg > (ADC_AMOUNT * 2) )	return MS_BADADDR;
	
	// if the input is odd the get the new adc value
	if ( !(wReg % 2) )
	{
  		// You must divide the wReg value by 2 when getting the proper channel	
		calVal = anaInVolts(wReg/2,ADC_GAINCODE);    
		// move the adc float value int a holding array of 4 bytes
		*(float *) & uiVal[0] = calVal;
		// copy the first 2 bytes of the holding array into the register value
		*pwValue = uiVal[0];    
	}
	// if the register is even
	else
	{
		// copy the last 2 bytes of the holding array into the register value.
		// DO NOT recalculate the input value.
		*pwValue = uiVal[1];	   
	}
	return 0;
}

/******************* End of Modbus Functions  ******************************/


/******************* Main Function *****************************************\

	Basic setup of the controller.  Once Modbus is setup, a call to msRun()
	needs to be called continually called.  Other functionalities can be
	added as long as they do not block. (i.e while loops for loops etc.).

\***************************************************************************/

void main(void)
{
	auto int loop;
	// Clear the output shadow arrays at startup of this sample
	memset(acShad, 0, sizeof(acShad));	
		  
	// initialize the SBC
	brdInit();
	devPowerSet(RS485DEV, 1);   
	
#if	(!MODBUS_TYPE)	 
	// Open Serial port D in ASCII mode 
	msaFinit(SLAVE_ADDRESS, MODBUS_BAUDRATE);
#else
	// Open Serial port D in RTU mode
	msrFinit(SLAVE_ADDRESS, MODBUS_BAUDRATE);  
#endif
	// If there are analog outputs required, get the cal. constants from the  
	// eeprom.
 	for( ;; )								
	{
 		// Modbus slave handler function.  It must be in a continous loop.
		msRun();     
		//	Other Costates Here!!! (Make sure your code does not block.)
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩免费观看一区二区三区| 精品伦理精品一区| 久久se精品一区精品二区| 国产精品天美传媒| 欧美日韩三级视频| va亚洲va日韩不卡在线观看| 日本欧美一区二区| 亚洲午夜精品久久久久久久久| 欧美一区三区四区| 欧美日韩国产首页在线观看| 97超碰欧美中文字幕| 丁香激情综合五月| 国产精品99久久不卡二区| 日韩国产欧美在线视频| 午夜影院久久久| 一区二区三区在线观看视频| 国产精品福利一区二区三区| 国产精品亚洲综合一区在线观看| 亚洲国产裸拍裸体视频在线观看乱了| 成人免费在线视频| 日韩美女啊v在线免费观看| 久久精品免视看| 成人理论电影网| 成人性生交大片免费看视频在线 | 欧美高清性hdvideosex| 色哟哟国产精品免费观看| 91女厕偷拍女厕偷拍高清| 91蝌蚪porny九色| 日本午夜精品一区二区三区电影 | 国产欧美日韩卡一| 国产日韩在线不卡| 亚洲日本青草视频在线怡红院| 国产精品灌醉下药二区| 亚洲黄色小视频| 丝瓜av网站精品一区二区| 日本成人在线不卡视频| 久久不见久久见免费视频1| 国产亚洲欧美在线| 亚洲国产成人自拍| 亚洲精品中文在线影院| 午夜久久电影网| 精品一区二区影视| 成人午夜看片网址| 欧美在线观看一区二区| 日韩免费视频一区二区| 国产日本亚洲高清| 18成人在线视频| 日韩av在线发布| 国产精品1024| 在线观看一区二区精品视频| 欧美刺激脚交jootjob| 久久精品无码一区二区三区| 日韩一区在线免费观看| 日韩 欧美一区二区三区| 国产盗摄精品一区二区三区在线| 不卡视频一二三| 91精品国产一区二区| 欧美国产日韩一二三区| 日韩电影一二三区| 91免费版在线看| 精品国产亚洲在线| 亚洲高清视频在线| 国产不卡一区视频| 日韩免费在线观看| 亚洲第一主播视频| 99久免费精品视频在线观看| 精品免费视频一区二区| 亚洲福中文字幕伊人影院| 国产成人综合亚洲网站| 日韩午夜在线影院| 亚洲国产视频在线| 99久久精品99国产精品| 久久嫩草精品久久久精品 | 欧美一级爆毛片| 亚洲欧洲国产日本综合| 国产精品一色哟哟哟| 欧美色图第一页| 国产精品不卡一区二区三区| 亚洲成人7777| 色婷婷综合在线| 国产精品久久久久久久久久久免费看 | 99热国产精品| 国产乱码字幕精品高清av | 国产蜜臀97一区二区三区| 欧美大片在线观看一区二区| 亚洲综合成人网| 91色porny蝌蚪| 国产精品美女久久久久久2018| 另类成人小视频在线| 欧洲一区在线电影| 亚洲欧美日韩国产综合在线| 成人晚上爱看视频| 国产欧美日韩综合| 国产乱码精品一区二区三区忘忧草| 91精品黄色片免费大全| 天涯成人国产亚洲精品一区av| 97精品久久久午夜一区二区三区| 国产精品国产成人国产三级 | 久久美女艺术照精彩视频福利播放| 美女高潮久久久| 欧美乱熟臀69xxxxxx| 亚洲一区免费在线观看| 欧美性大战xxxxx久久久| 亚洲综合色网站| 欧美日韩国产美女| 午夜视频在线观看一区二区 | 国产麻豆视频精品| 日韩一本二本av| 亚洲bt欧美bt精品| 欧美日本在线播放| 奇米影视一区二区三区| 欧美日韩高清一区| 奇米精品一区二区三区在线观看 | 激情综合网激情| 久久精品亚洲麻豆av一区二区| 国产成人激情av| 日本一区二区动态图| 91丨九色porny丨蝌蚪| 亚洲一区二区高清| 欧美一级高清大全免费观看| 精品中文字幕一区二区小辣椒| 久久九九99视频| 91免费视频网址| 日韩高清一级片| 久久亚洲一区二区三区四区| 成人av网站在线| 亚洲精品一卡二卡| 欧美一区二区三区影视| 国产精品一区二区你懂的| 国产精品久久久久久妇女6080 | 中文字幕视频一区二区三区久| 欧美在线影院一区二区| 麻豆成人综合网| 亚洲视频电影在线| 4438成人网| 成人免费看的视频| 同产精品九九九| 中文字幕av资源一区| 欧美高清性hdvideosex| 国产91色综合久久免费分享| 亚洲一级二级在线| 国产日产精品一区| 日韩视频一区二区三区在线播放 | 中文字幕在线观看一区| 日韩区在线观看| 91福利资源站| 国产精品123区| 久久精品免费观看| 中文字幕一区二区三| 91精品国产日韩91久久久久久| 成人开心网精品视频| 久久精品国产一区二区三 | 91在线视频18| 国产精品久久福利| 欧美一级免费大片| 91在线观看一区二区| 美腿丝袜在线亚洲一区| 亚洲三级电影网站| 国产欧美综合在线观看第十页| 蜜桃av一区二区在线观看| 亚洲日韩欧美一区二区在线| 久久综合色鬼综合色| 日韩欧美在线网站| 欧美日韩黄视频| 色域天天综合网| 99vv1com这只有精品| 国产成人精品免费在线| 久久国产精品第一页| 日韩精品五月天| 亚洲成人动漫在线免费观看| 亚洲免费在线播放| 欧美高清在线一区| 国产精品免费丝袜| 久久精品无码一区二区三区| 欧美精品一区二区三区很污很色的| 欧美蜜桃一区二区三区| 91国偷自产一区二区三区观看| 色综合久久久久久久| 91视频你懂的| 色综合视频一区二区三区高清| 一区二区三区在线免费视频| 亚洲人成影院在线观看| 中文字幕在线观看一区二区| 中文字幕亚洲成人| 最新国产の精品合集bt伙计| 中文字幕一区二区三区乱码在线| 中文字幕不卡在线观看| 7799精品视频| 色哟哟一区二区在线观看| 99精品桃花视频在线观看| 成人美女在线观看| aa级大片欧美| 色老头久久综合| 欧美久久久久中文字幕| 宅男在线国产精品| 欧美成人r级一区二区三区| 337p粉嫩大胆噜噜噜噜噜91av| 久久久久国产精品麻豆ai换脸| 国产精品色婷婷| 亚洲一二三四区|