Sou iniciante em c++ 2010 express, necessito enviar várias array's de bytes em hexa pela serial para lcd touch. Tentei usar como se fosse C pára microcontrolador, mas não deu resultado (óbvio).
Este é o conteúdo do meu arquivo mensagem.h
cpp code
#include <string> // at the top of the file
array<char>^ botao1[12]={0xF1,0x0A,0xFB,0xA4,0x01,0x08,0x00,0x1A,0x00,0x04,0xC6,0xF4};
A minha parte do código para enviar os bytes pela serial, mas não funciona.
cpp code
#include "mensagens1.h"
#pragma once
//#include <string> // at the top of the file
//#include "mensagens1.h"
namespace part1 {
using namespace System;
.
.
.
.
String^ message = this->textBox2->Text;
if(this->serialPort1->IsOpen)
{
if(message !="1")
{
unsigned char i;
this->textBox2->Text="numero 1";
for ( i = 0; i < 12; i++ )
{
SerialPort1.Write(Convert.ToChar(botao1[i]))
}
}
else
this->textBox2->Text="diferente de 1";
}
else
.
.
.
li que tenho que converter como exemplo abaixo. Tá correto? Como adapto para várias array's diferentes.
Agradeço ajuda.
cpp code
serialPort1->Open();
array<unsigned char,1>^ buf = gcnew array<unsigned char,1>(3){0x0A, 0xE2, 0xFF};
// Now write the bytes
serialPort1->Write(buf,0,buf->Length);
serialPort1->Close();