//---------------------------------------------------------------------------

#ifndef RS485Test_FormH
#define RS485Test_FormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Grids.hpp>
#include "TntGrids.hpp"
#include "TntStdCtrls.hpp"
#include "TntForms.hpp"

#define RX485_MASTER_RX_BUFFER_SIZE		64
#define MODBUS_RTU_HEADER_SIZE			3
#define MODBUS_RTU_CRC_SIZE				2
//---------------------------------------------------------------------------
class TRS485TestForm : public TTntForm
{
__published:	// IDE-managed Components
	TTntEdit *InputEdit;
	TTntLabel *Label1;
	TTntButton *SubmitButton;
	TTntLabel *Label2;
	TTntLabel *SentDataLabel;
	TTntLabel *Label4;
	TTntLabel *ReceivedDataLabel;
	TTimer *RXCheckTimer;
	TTntLabel *Label3;
	TTntLabel *ProtocolResultLabel;
	TTntGroupBox *GroupBox1;
	TTntStringGrid *DebugInfoStringGrid;
	TTntButton *ReadDebugInfoButton;
	void __fastcall SubmitButtonClick(TObject *Sender);
	void __fastcall RXCheckTimerTimer(TObject *Sender);
	void __fastcall ReadDebugInfoButtonClick(TObject *Sender);
private:	// User declarations
	unsigned char RXData[RX485_MASTER_RX_BUFFER_SIZE];
	int RXLength;

	void __fastcall DecodePacket(void);
public:		// User declarations
	__fastcall TRS485TestForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TRS485TestForm *RS485TestForm;
//---------------------------------------------------------------------------
#endif
