Home
Home copied to clipboard
STM32F769I DISCOVERY Inconsistent SerialPort WatchChar behaviour after erase->power cycle->run & erase->run
Library/API/IoT binding
System.IO.Ports
Visual Studio version
VS2022 17.2.1
.NET nanoFramework extension version
2022.0.0.19
Target name(s)
ST_STM32F769I_DISCOVERY
Firmware version
1.8.0.105
Device capabilities
System Information HAL build info: nanoCLR running @ ST_STM32F769I_DISCOVERY Target: ST_STM32F769I_DISCOVERY Platform: STM32F7
Firmware build Info: Date: May 11 2022 Type: MinSizeRel build with ChibiOS v2021.11.1.11 CLR Version: 1.8.0.105 Compiler: GNU ARM GCC v10.3.1
OEM Product codes (vendor, model, SKU): 0, 0, 0
Serial Numbers (module, system): 00000000000000000000000000000000 0000000000000000
Target capabilities: Has nanoBooter: YES nanoBooter: v1.8.0.105 IFU capable: NO Has proprietary bootloader: NO
AppDomains:
Assemblies: BreakOutSerial, 1.0.0.0 System.IO.Ports, 1.0.4.3 mscorlib, 1.12.0.4 nanoFramework.Runtime.Events, 1.10.0.3 nanoFramework.System.Text, 1.1.3.3 System.IO.Streams, 1.0.0.2
Native Assemblies: mscorlib v100.5.0.17, checksum 0x004CF1CE nanoFramework.Runtime.Native v100.0.9.0, checksum 0x109F6F22 nanoFramework.Hardware.Stm32 v100.0.4.4, checksum 0x0874B6FE nanoFramework.Devices.Can v100.0.5.0, checksum 0xF319D40E nanoFramework.Graphics v100.0.0.3, checksum 0xB3EDAF22 nanoFramework.Device.OneWire v100.0.4.0, checksum 0xB95C43B4 nanoFramework.Networking.Sntp v100.0.4.4, checksum 0xE2D9BDED nanoFramework.ResourceManager v100.0.0.1, checksum 0xDCD7DF4D nanoFramework.System.Collections v100.0.1.0, checksum 0x2DC2B090 nanoFramework.System.Text v100.0.0.1, checksum 0x8E6EB73D nanoFramework.Runtime.Events v100.0.8.0, checksum 0x0EAB00C9 EventSink v1.0.0.0, checksum 0xF32F4C3E System.IO.FileSystem v1.0.0.0, checksum 0x3AB74021 System.Math v100.0.5.4, checksum 0x46092CB1 System.Net v100.1.4.1, checksum 0xA01012C3 System.Device.Adc v100.0.0.0, checksum 0xE5B80F0B System.Device.Dac v100.0.0.6, checksum 0x02B3E860 System.Device.Gpio v100.1.0.4, checksum 0xB6D0ACC1 System.Device.I2c v100.0.0.1, checksum 0xFA806D33 System.Device.Pwm v100.1.0.4, checksum 0xABF532C3 System.IO.Ports v100.1.4.0, checksum 0xCB7C0ECA System.Device.Spi v100.1.2.0, checksum 0xB6C4B3BD Windows.Storage v100.0.2.0, checksum 0x954A4192
Description
Working on LoRaWAN module library which sends AT Commands to device. Commands are short 1-20 chars, responses can 4-100 chars (though mainly just "OK" +\r\n)
I erase and power cycle my device regularly when testing/debugging so that when I start my program the LoRaWAN modem doesn't get sent commands and is in a known state.
After an erase/power cycle the device the SerialData.WatchChar event didn't appear to fire at all/reliably. (SerialData.Chars wasn't either)
The second time I run the application SerialData.WatchChar events as expected
After just an erase on the first run watchchar events didn't appear to fire reliably(better than after erase power cycle). Then on second run SerialData.WatchChar events were reliable.
How to reproduce
Should be able to repro with ST_STM32F769I_DISCOVERY + sample code from #1035...
- Connect device erase then power cycle.
- Run application the WatchChar event will not fire (or maybe unreliable)
- Run application again the WatchChar event will fire reliably
- Erase device
- Run application WatcCharevent will fire unreliably (though more reliably than 2. )
- Run application WatchChar event will fire reliably
Expected behaviour
WatchChar should fire reliably when device is eerase and/or power cycled
Screenshots
Sample project or code
I used the SerialCommunication sample
Requires small mods to Scenario1_ConfigureDevice.cs & Scenario4_DataReceivedEvent.cs to repro. I used a serial device that responded to Hayes AT Commands, but a simple serial loopback (TX pin connected to RX pin on device) should work
Around line 30 in Scenario4_DataReceivedEvent.cs
serialDevice.NewLine = "\r\n";
serialDevice.WriteLine("at+version"); // Added this line to send short message
// set a watch char to be notified when it's available in the input stream
//serialDevice.WatchChar = '\n'; // Commented out this line
Debug.WriteLine("Waiting to receive data in serial port...");
Around line 72 in Scenario1_ConfigureDevice.cs
_serialDevice.ReadBufferSize = 2048;
_serialDevice.WatchChar = '\n'; // Before Open WatchChar event doesn't fire
// open the serial port with the above settings
_serialDevice.Open();
_serialDevice.WatchChar = '\n'; // After Open WatchChar event fires
Aditional information
Possibly related to #1035.
I think ESP32 device works as expected
Fixed up formatting of sample code
@KiwiBryn stupid question: have you tried with an ESP32? And is it the same issue? Or it's STM32 specific?
@Ellerbach I think this is STM specific, ESP32 has different but maybe related WatchChar issue (see my Q in Discord/general)
@KiwiBryn can you please retest with more recent images? I've just released a bunch of fixes related with UART.