|
BC++ Charon 1 Communication Example
This is an example of plain communication with general TCP/IP devices in Borland C++ Builder 6.00.
Its show simple Client Terminal and base commands NVT (Network Virtual Terminal) = Are You There and widespread for I/O function.
The application is very simple, that is for demonstrative purpose only and you can use it for own applications.
Focus is primarily sight on proper solution of Ethernet parts, including detection of enclosure connection from parties server.
You can control I/O pins by NVT in your application (in this example were use for control LED and for backward reading turn ON/OFF).
It's useful, because you can't study NVT documentation.
Function description
-
void __fastcall Image1Click(TObject *Sender);
void __fastcall Label3Click(TObject *Sender);
Function start web page (www.hwgroup.cz) in default HTML viewer.
-
void __fastcall ConnectBtnClick(TObject *Sender);
Function is called after key press Connect(Disconnect), whether is ClientSocket in active state. It's make TCP connection with module.
If not establish a connection is hand over request to make connection.
- void __fastcall WriteLEDBtnClick(TObject *Sender);
Function make NVT commands according to checkbox and whether is establish connection so data is sent by ClientSocket object.
- void __fastcall ClientSocketConnect(TObject *Sender, TCustomWinSocket *Socket);
Function call system after made connection with TCP client, then sent AYT (Are You There) command to NVT module.
- void __fastcall ClientSocketError(TObject *Sender, TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode);
Function is called by system if come error on TCP connection.
- void __fastcall ClientSocketRead(TObject *Sender, TCustomWinSocket *Socket);
Function is called by system whether data is received from socket.
Received chars are showed in window Meno, each TCP scope on whole line.
If data stream contain sing 0xFF its operate as state automatic machine.
Whether is received sing 0xFF and if next sign isn't sign 0xFF, it's begin of NVT sequence then it switch to isNVT state.
As far as sign 0XFF is following sign 0xFA, it's it start of enlargement NVT command then it switch to isNVStart state.
Sequence 0xFF 0xF0 mean end of NV command.
Next data is displayed in a way normal.
- void __fastcall FormCreate(TObject *Sender);
Function is called whaen is made main application window.
- void __fastcall AYTBtnClick(TObject *Sender);
Function is called by press on AYT key. If made-up connection with module, function send AYT (Are You There) command.
- void __fastcall ClearBtnClick(TObject *Sender);
Function is called by press on button with ash bin symbol and erase window with received data.
- void __fastcall ReadLEDBtnClick(TObject *Sender);
Function send query on state input to module. Aswer is evaluate till receive data by function ClientSocketRead.
- void __fastcall SendBtnClick(TObject *Sender);
On press button Send is converted data from entry edit box and send it, whether is made-up connection with module.
- void __fastcall FormDestroy(TObject *Sender);
Function is called after close application window. IP value and Port value is wrote to .ini file.
- bool CheckHEX( AnsiString S, AnsiString &GO);
Function check whether entry line contain right sequence HEX number for write,
whether its OK, it's converted to binary sequence and is stored to GO string.
- void __fastcall SendHEXBtnClick(TObject *Sender);
Function call conversion entry line in HEX. As far as is everything in order and is make-up TCP connection, data in binary format is send into module.
- void __fastcall ClientSocketDisconnect(TObject *Sender, TCustomWinSocket *Socket);
Function is call by system when is stoped TCP connection.
- void TMainFrm::HandleButtons(bool Active);
Function set enable/disable keys and input components accordinfg to variable Active.
- void __fastcall TMainFrm::WriteaReadBtnClick(TObject *Sender);
Function call function WriteLEDClick a RedLEDClick
More support Examples
Download programing code and .EXE files
-
bcc_ch1com_example.zip
- /Source = MainForm.cpp, MainForm.dfm, CharonDemo.cpp, CharonDemo.bpr and onther programming code.
- /Program = CharonDemo.exe, CharonDemo.ini
|