#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 500
#End Region
'
Sub Process_Globals
Public Serial1 As Serial 'Serial connection for Debug..
Public Serial2 As SoftwareSerial
Public astream As AsyncStreams
Public timer As Timer
'
End Sub
'
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")'
'
Serial2.Initialize(9600,12,14) 'pin ESP07
astream.Initialize(Serial2.Stream,"astream_newdata","astream_error")
'
timer.Initialize("timer_Tick",2000)
timer.Enabled=True
End Sub
Sub timer_Tick
Log("tick")
Dim msg() As Byte ="hallo"
astream.Write(msg)
End Sub
Sub astream_newdata (Buffer() As Byte) '
Log("from esp:",Buffer)
End Sub
'
Sub astream_error
Log("Serial - No Connection")
End Sub
Yes, I have the same trouble. In the past I have success with pin 12 and 14, but now it is not functioned. Very interresting is that Sendig is OK, but receiving in NOT ok.Just to note I have successfully used pins 12 (D6) and 14 (D5) for Software Serial in the past.
Very interesting indeed.Barx,
Yes, I have the same trouble. In the past I have success with pin 12 and 14, but now it is not functioned. Very interresting is that Sendig is OK, but receiving in NOT ok.
I have 2 peaces of HW, one old and one absolute new. On both is this trouble. I have tried the same - create new project in b4r, but this not sole this situation.
I am using same board settings.
p4ppc
AsyncStreams::checkForData
// ::Serial.print("is connected: ");
We're just 2 people trying to figure the same problem ?Thank you for your tips Barx
swserial.Initialize(9600,12,14)
If swserial.Stream.BytesAvailable> 1 Then
Dim b(swserial.Stream.BytesAvailable) As Byte
Dim len As Int = swserial.Stream.ReadBytes(b, 0, b.Length)
Log (b)
End If
void AsyncStreams::checkForData(void* b)
int av = me->stream->BytesAvailable();
AsyncStreams* me = (AsyncStreams*) b;
Int i = wrappedStream->readBytes(((Byte*)Buffer->data + StartOffset + total), MaxCount);
::Serial.println(wrappedStream->readBytes(((Byte*)Buffer->data + StartOffset + total), MaxCount));
if (index > 0 && (!me->prefixMode || index == maxSize)) {
arr->length = index;
sender->wrapPointer(b);
B4R::StackMemory::cp += index;
::Serial.print("Lib - Data4");
me->NewDataSub(arr);
}
If swserial.Stream.BytesAvailable> 1 Then
Dim b(swserial.Stream.BytesAvailable) As Byte
Dim len As Int = swserial.Stream.ReadBytes(b, 0, b.Length)
Log ("b4r - ", b)
Log ("Length = ", len)
Else
Log("No data")
End If
This is the documentation of Stream.readBytes: https://www.arduino.cc/reference/en/language/functions/communication/stream/streamreadbytesThe returned value 'i' is -1.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?