Testovani HardwareSerial
This commit is contained in:
@ -72,7 +72,9 @@
|
||||
|
||||
#define CORS_DEBUG
|
||||
|
||||
#define TX_PIN 1
|
||||
#define RX_PIN 3
|
||||
//#define TX_PIN 1
|
||||
#define TX_PIN 14
|
||||
//#define RX_PIN 3
|
||||
#define RX_PIN 12
|
||||
|
||||
#endif
|
||||
|
17
src/vsp.ino
17
src/vsp.ino
@ -157,7 +157,11 @@ void setserialport(int32_t speed, int32_t databits, int32_t parity, int32_t stop
|
||||
// delay(200);
|
||||
SP.end();
|
||||
delay(10); // 100
|
||||
SP.begin(spd, (SerialConfig)serialMode);
|
||||
#if (TX_PIN != 1) || (RX_PIN != 3)
|
||||
SP.begin(spd);
|
||||
#else
|
||||
SP.begin(spd, (SerialConfig)serialMode);
|
||||
#endif
|
||||
delay(10); // 100
|
||||
SP.flush();
|
||||
serial_tx = 0;
|
||||
@ -168,7 +172,11 @@ void setserialport(int32_t speed, int32_t databits, int32_t parity, int32_t stop
|
||||
void sputchar(uint8_t c)
|
||||
{
|
||||
|
||||
#if (TX_PIN != 1) || (RX_PIN != 3)
|
||||
if (1)
|
||||
#else
|
||||
if (fromNet.empty() && SP.availableForWrite())
|
||||
#endif
|
||||
{
|
||||
SP.write(c);
|
||||
++serial_tx;
|
||||
@ -375,8 +383,15 @@ void vsp_loop()
|
||||
}
|
||||
|
||||
// testovani, zda neposlat nejaka data do serioveho rozhrani
|
||||
|
||||
#if (TX_PIN != 1) || (RX_PIN != 3)
|
||||
if (!fromNet.empty())
|
||||
{
|
||||
len = 1;
|
||||
#else
|
||||
if (!fromNet.empty() && (len = SP.availableForWrite()))
|
||||
{
|
||||
#endif
|
||||
size_t will_copy = (len < sizeof(sbuf)) ? len : sizeof(sbuf);
|
||||
will_copy = fromNet.read((char *)sbuf, will_copy);
|
||||
SP.write(sbuf, will_copy);
|
||||
|
Reference in New Issue
Block a user