I added an EMIC 2 speech synthesizer to my robot project.
It works beautifully.
When it finishes speaking, it sends a colon ":" our of its serial port.
That serial data is received on the Hardware Serial Port 2 of my Arduino Mega 2560.
Since it has no carriage return, the data is not seen by the Arduino.
Is there any way to fix this?
Line 55 of my code below is not sending anything. But it works correctly in other instances.
This is the relevant code:
It works beautifully.
When it finishes speaking, it sends a colon ":" our of its serial port.
That serial data is received on the Hardware Serial Port 2 of my Arduino Mega 2560.
Since it has no carriage return, the data is not seen by the Arduino.
Is there any way to fix this?
Line 55 of my code below is not sending anything. But it works correctly in other instances.
This is the relevant code:
My B4R Code:
Sub Process_Globals
'TXD2/RXD2 Serial for EMIC 2 Text to Speech Synthesizer. See: D:\Electronics\Data Sheets\Emic 2 Text to Speech Module
Private SerialNative2 As Stream 'https://www.b4x.com/android/forum/threads/additional-hardware-serial-ports.67150/
Private Emic2Stream As AsyncStreams
End Sub
Private Sub AppStart
'Serial for EMIC 2 Text to Speech Synthesizer connected to Hardware Serial Port 1.
RunNative("SerialNative2", Null)
Emic2Stream.Initialize(SerialNative2, "Emic2Stream_NewData", Null)
Delay(2000)
CommandEMIC2("H","")
Delay(5000)
For VoiceNumber = 0 To 8
CommandEMIC2("N",VoiceNumber)
Delay(1000)
CommandEMIC2("V", 18)
Delay(1000)
Speak("Hello! My name is Emic 2. Nice to meet you.")
Delay(5000)
Next
End Sub
Private Sub Speak(SendData As String)
Private eol2() As Byte = Array As Byte(13)
Dim SendData As String = JoinStrings(Array As String("S", SendData))
'Log("Send Data = ", SendData)
'Send data to EMIC 2 connected to Hardware Serial Port 2.
Dim Buffer() As Byte = SendData
Emic2Stream.Write(Buffer)
Emic2Stream.Write(eol2) 'end of line character. AsyncStreamsText will cut the message here
End Sub
Private Sub CommandEMIC2(SendData1 As String, SendData2 As String)
Private eol2() As Byte = Array As Byte(13)
Dim SendData As String = JoinStrings(Array As String(SendData1, SendData2))
Log("Command Data = ", SendData)
'Send data to EMIC 2 connected to Hardware Serial Port 2.
Dim Buffer() As Byte = SendData
Emic2Stream.Write(Buffer)
Emic2Stream.Write(eol2) 'end of line character. AsyncStreamsText will cut the message here
End Sub
Private Sub Emic2Stream_NewData (Buffer() As Byte) 'Data from EMIC 2 Text to Speech Synthesizer
Log("Buffer = ", Buffer)
Private eol2() As Byte = Array As Byte(13)
PCStream.Write(Buffer) 'Send data out via Bluetooth connection to bluetooth receiver on the PC.
PCStream.Write(eol2) 'end of line character. AsyncStreamsText will cut the message here
End Sub