//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" #include "PACSDK.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { edConnStr->Text = "COM2,115200,N,8,1"; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { byte cmd[64]; byte result[64]; HANDLE h = uart_Open(edConnStr->Text.c_str()); //the default timeout value for uart_SendCmd may be too short to receive. uart_SetTimeOut(h, 1000, CTO_TIMEOUT_ALL); strcpy(cmd, edSend->Text.c_str()); uart_SendCmd(h, cmd, result); edReceive->Text = AnsiString((char *)result); uart_Close(h); } //---------------------------------------------------------------------------