Arduino Serial Monitor给出了我的输出的问号和框

发布于 2025-01-24 21:11:26 字数 1413 浏览 5 评论 0原文

我正在编写一个程序来加密给定的输入并将密码文本发送到Lora Wave上,但我似乎被困在此步骤中。 我正在使用Heltec Lora ESP32,并包括用于AES函数的MBEDTLS库。

#include "mbedtls/aes.h"
#include "heltec.h"
#include <SPI.h>

#define BAND    433E6 //setting the LoRa bands to 433 mhz
mbedtls_aes_context aes;

int counter = 0;

unsigned char key[32] = "key"; // 256 bit - AES = 32 bytes for key
unsigned char iv[16];

unsigned char input [128] = "given AES plain text";
unsigned char output[128];

size_t input_len = 40;
size_t output_len = 0;

void setup() {
  Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
  //setup code to enable LoRa
  
  Serial.begin(115200); //establishing serial communication with esp32 and pc

  mbedtls_aes_setkey_enc( &aes, key, 256 );
  mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, 48, iv, input, output ); // AES function from mbedtls library,
}

void loop() {

  Serial.print("Sending packet: ");
  Serial.println(counter);
  Serial.println((char*)output); //here is the issue

  // send packet
  LoRa.beginPacket();
  LoRa.print((char*)output);
  LoRa.print(counter);
  LoRa.endPacket();
  
  counter++;
  delay(5000);

}

输出给出一个包含(IM假设)特殊字符的密码文本,当我查看Arduino串行显示器时,它显示了带有正常字符的一堆反向问号和框。

Serial.println((char*)output);

是否有可以在Arduino IDE中显示这些特殊字符的打印方法?

I am writing a program to encrypt the given input and send the cipher text over LoRa waves, but I seem to be stuck in this step.
I am using a Heltec LoRa ESP32 and have included the mbedtls library for the AES functions.

#include "mbedtls/aes.h"
#include "heltec.h"
#include <SPI.h>

#define BAND    433E6 //setting the LoRa bands to 433 mhz
mbedtls_aes_context aes;

int counter = 0;

unsigned char key[32] = "key"; // 256 bit - AES = 32 bytes for key
unsigned char iv[16];

unsigned char input [128] = "given AES plain text";
unsigned char output[128];

size_t input_len = 40;
size_t output_len = 0;

void setup() {
  Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
  //setup code to enable LoRa
  
  Serial.begin(115200); //establishing serial communication with esp32 and pc

  mbedtls_aes_setkey_enc( &aes, key, 256 );
  mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, 48, iv, input, output ); // AES function from mbedtls library,
}

void loop() {

  Serial.print("Sending packet: ");
  Serial.println(counter);
  Serial.println((char*)output); //here is the issue

  // send packet
  LoRa.beginPacket();
  LoRa.print((char*)output);
  LoRa.print(counter);
  LoRa.endPacket();
  
  counter++;
  delay(5000);

}

the output gives a cipher text containing (Im assuming) special characters and when I look at the Arduino serial monitor it shows bunch of reverse question marks and boxes with normal characters.

Serial.println((char*)output);

Is there a print method that can show these special characters in the Arduino IDE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把回忆走一遍 2025-01-31 21:11:26
Serial.begin(115200);

串行Montority Baud的价值应与上述价值相同。

Serial.begin(115200);

The value of serial monitory baud should be same as above value.
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文