Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Message.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13. : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::Button1Click(TObject *Sender)
  18. {
  19. if (serie1.OpenOk("COM6")==1) ShowMessage("Ok");
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::Button2Click(TObject *Sender)
  23. {
  24. serie1.Close();
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TForm1::Button4Click(TObject *Sender)
  28. {
  29. AnsiString Phrase;
  30. Phrase=Edit2->Text;
  31. int taille = Phrase.Length();
  32. char tabPhrase[256];
  33. strcpy(tabPhrase,Phrase.c_str());
  34. unsigned char tabBuffer[256];
  35. tabBuffer[0]= 0x00;
  36. tabBuffer[1]= 0x00;
  37. tabBuffer[2]= 0x00;
  38. tabBuffer[3]= 0x00;
  39. tabBuffer[4]= 0x00;
  40. tabBuffer[5]= 1;
  41. tabBuffer[6]= 'z' ;
  42. tabBuffer[7]= '0';
  43. tabBuffer[8]= '0';
  44. tabBuffer[9]= 2;
  45. tabBuffer[10]= 'A';
  46. tabBuffer[11]= 'A';
  47. for (int i=0; i<taille; i++){
  48. tabBuffer[12+i]= tabPhrase[i]; }
  49. tabBuffer[12+taille] = 4;
  50. serie1.Transmit(tabBuffer, taille+13);
  51. Sleep(100);
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TForm1::Button3Click(TObject *Sender)
  55. {
  56. {
  57. serie1.SetProtocol(ComboBox1->Text.ToInt(),ComboBox2->Text.ToInt(),ComboBox4->ItemIndex, ComboBox3->ItemIndex);
  58. }
  59. }
  60. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement