#include "stdafx.h" #include<iostream> using namespace std; using namespace System::IO::Ports; using namespace System; typedef unsigned char byte; int main() { SerialPort^ sp=gcnew SerialPort("COM1",115200); sp->Open(); if(sp->IsOpen) cout<<"port opened."<<endl; array<byte>^bytes = gcnew array<byte>(8); bytes[0]=0x10; bytes[1]=0x01; bytes[2]=0x03; bytes[3]=0x20; bytes[4]=0x01; bytes[5]=0x02; bytes[6]=0x88; bytes[7]=0xA8; sp->Write(bytes, 0, 8); cout<<sp->ReadByte()<<"first\n"; cout<<sp->ReadByte()<<"second\n"; cout<<sp->ReadByte()<<"third\n"; //cout<<s<<"\n"; return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)