mrossen Active Member Licensed User Longtime User Apr 11, 2018 #1 Hi, I have made a scenario where I use astream.Initializeprefix on both the WiFi and Serial streams with a ESP8266 module Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initializeprefix(SerialCom.Stream, False, "astreamCom_NewData", "astreamCom_Error") If I do that I get the 4 prefix bytes in the begining when I receive data from serial to WiFi. And I am then missing the 4 last bytes! I dont know why? Anyone can explain that? If I not using the prefix mode I get the hole data set include the first 4 bytes Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initialize(SerialCom.Stream, False, "astreamCom_NewData", "astreamCom_Error") Mogens
Hi, I have made a scenario where I use astream.Initializeprefix on both the WiFi and Serial streams with a ESP8266 module Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initializeprefix(SerialCom.Stream, False, "astreamCom_NewData", "astreamCom_Error") If I do that I get the 4 prefix bytes in the begining when I receive data from serial to WiFi. And I am then missing the 4 last bytes! I dont know why? Anyone can explain that? If I not using the prefix mode I get the hole data set include the first 4 bytes Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initialize(SerialCom.Stream, False, "astreamCom_NewData", "astreamCom_Error") Mogens
Erel B4X founder Staff member Licensed User Longtime User Apr 11, 2018 #2 What is connected to the other side of the serial connection? Upvote 0
mrossen Active Member Licensed User Longtime User Apr 11, 2018 #3 A device there also uses the prefix mode. I have the same setup (Android <--> Bluetooth <--> device) with a bluetooth module. This works fine. It is a standard bluetooh module, where I not have made the software for. Upvote 0
A device there also uses the prefix mode. I have the same setup (Android <--> Bluetooth <--> device) with a bluetooth module. This works fine. It is a standard bluetooh module, where I not have made the software for.
Erel B4X founder Staff member Licensed User Longtime User Apr 12, 2018 #4 Why are you using pin 0 for SoftwareSerial? This is the pin that is used by the hardware serial port. Upvote 0
Why are you using pin 0 for SoftwareSerial? This is the pin that is used by the hardware serial port.
mrossen Active Member Licensed User Longtime User Apr 12, 2018 #5 The AI Thinker module have only GPIO0 and GPIO02 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Apr 12, 2018 #6 If this pin is used for other things then it will add "garbage" to the connection and will cause problems. Especially with prefix mode. Upvote 0
If this pin is used for other things then it will add "garbage" to the connection and will cause problems. Especially with prefix mode.
mrossen Active Member Licensed User Longtime User Apr 12, 2018 #7 So I have to use the RX and TX pins? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Apr 12, 2018 #8 No. You need to use two pins that are not used for anything else. Upvote 0
mrossen Active Member Licensed User Longtime User Apr 12, 2018 #9 But I dont have. So I can not use this module ? See. here: https://www.google.dk/search?q=AI+t...AUICigB&biw=1920&bih=955#imgrc=KQHN-Bwx8soLAM: Upvote 0
But I dont have. So I can not use this module ? See. here: https://www.google.dk/search?q=AI+t...AUICigB&biw=1920&bih=955#imgrc=KQHN-Bwx8soLAM:
mrossen Active Member Licensed User Longtime User Apr 12, 2018 #10 I have look in Espressif Systems Documentation. It look like that GPIO1 is TX and GPIO3 is RX? And GPIO0 / GPIO2 are unused. Upvote 0
I have look in Espressif Systems Documentation. It look like that GPIO1 is TX and GPIO3 is RX? And GPIO0 / GPIO2 are unused.
mrossen Active Member Licensed User Longtime User Apr 12, 2018 #11 Hi, I have made the same setup with a Wemos D1 R2. I use GPIO4 & GPIO5 as RX/TX. This is the same result. This is what I receive : 000300160170018001902002100220802300 This is what I receive correct with Bluetooth: 01601700180019020021002208023002412825026000 Upvote 0
Hi, I have made the same setup with a Wemos D1 R2. I use GPIO4 & GPIO5 as RX/TX. This is the same result. This is what I receive : 000300160170018001902002100220802300 This is what I receive correct with Bluetooth: 01601700180019020021002208023002412825026000
Erel B4X founder Staff member Licensed User Longtime User Apr 13, 2018 #12 I can only guess that there is some data left when you start reading from the serial port and it causes the prefix counting to be broken. Don't use prefix mode. Upvote 0
I can only guess that there is some data left when you start reading from the serial port and it causes the prefix counting to be broken. Don't use prefix mode.
mrossen Active Member Licensed User Longtime User Apr 28, 2018 #13 Now I got it to work, I change the "BigEndian" option to True instead of false. But I dont understand why this works. From Android/iPhone to ESP8266 I use the False, but then it has to be True from ESP8266 to my device? Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initializeprefix(SerialCom.Stream, True, "astreamCom_NewData", "astreamCom_Error") I also change the Code: Copy astreamCom.WaitForMoreDataDelay = 3 From 5 to 3. This seems to be more reliable. With the value = 5 the last bytes are wrong sometimes. Upvote 0
Now I got it to work, I change the "BigEndian" option to True instead of false. But I dont understand why this works. From Android/iPhone to ESP8266 I use the False, but then it has to be True from ESP8266 to my device? Code: Copy SerialCom.Initialize(9600, 2, 0) astreamCom.Initializeprefix(SerialCom.Stream, True, "astreamCom_NewData", "astreamCom_Error") I also change the Code: Copy astreamCom.WaitForMoreDataDelay = 3 From 5 to 3. This seems to be more reliable. With the value = 5 the last bytes are wrong sometimes.
Erel B4X founder Staff member Licensed User Longtime User Apr 29, 2018 #14 mrossen said: From Android/iPhone to ESP8266 I use the False, but then it has to be True from ESP8266 to my device? Click to expand... Doesn't sound correct. It should be the same on all platforms. You can try it with this example: https://www.b4x.com/android/forum/t...ceive-objects-instead-of-bytes.72404/#content Upvote 0
mrossen said: From Android/iPhone to ESP8266 I use the False, but then it has to be True from ESP8266 to my device? Click to expand... Doesn't sound correct. It should be the same on all platforms. You can try it with this example: https://www.b4x.com/android/forum/t...ceive-objects-instead-of-bytes.72404/#content