|
안녕하세요.
필요에 의해서 아두이노 처음 접하는, 일반 S/W 개발자 입니다.
(이쪽을 몰라서 바보같은 질문을 드릴수 있습니다.)
오랜지보드BLE 를 통해서,
블루투스 <-> RS232 의 컨버터를 만들려고 합니다.
SoftwareSerial를 사용해서, 단독으로 하면 데이터가 정상으로 확인되는데요,
2개의 SoftwareSerial, BLE와 RS232 를 만들면 손실되는 데이터가 많아서 정상의 데이터로 확인되지 않습니다.
데이터 손실없이 깔끔하게 전달하는 방법이 있는지 문의 드립니다.
감사합니다.
PS: 사용한 소스를 아래 첨부 합니다.
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
Not all pins on the Leonardo and Micro support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart's example
This example code is in the public domain.
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
SoftwareSerial BTSerial(4, 5);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(38400);
BTSerial.begin(9600);
}
void loop()
{ // run over and over
mySerial.listen();
while(0 < mySerial.available())
{
byte data = mySerial.read();
Serial.write(data);
BTSerial.write(data);
}
BTSerial.listen();
while(0 < BTSerial.available())
{
byte data = BTSerial.read();
Serial.write(data);
mySerial.write(data);
}
}
|