DCS-Skunkworks / dcs-bios-arduino-library

A library designed to run on Arduinos and similar microcontrollers and communicate with DCS-BIOS.
MIT License
60 stars 22 forks source link

STM32 Compile Issues #19

Open speedbird5 opened 2 years ago

speedbird5 commented 2 years ago

Hi, I cannot get a simple DCS-BIOS sketch to compile on my STM32F103C8 blue pill. I can however compile and upload the simple Blink sketch and another sketch which reads potentiometer outputs etc with no issues. I used the STM32duino board definitions. I have installed your Arduino library version 3.6 from here: https://github.com/talbotmcinnis/dcs-bios-arduino-library/releases/download/0.3.6/dcs-bios-arduino-library-0.3.6.zip I am using the Flight Panels DCS BIOS code.

Hers is the sketch code:

define DCSBIOS_DEFAULT_SERIAL

define DCSBIOS_FOR_STM32

include "DcsBios.h"

/ Declare a Master Caution Reset button on pin 10 / DcsBios::Switch2Pos ufcMasterCaution("UFC_MASTER_CAUTION", PB4); / Make the LED connected to pin 13 into a Master Caution Light / DcsBios::LED masterCaution(0x1012, 0x0800, PC13);

void setup() { DcsBios::setup(); }

void loop() { DcsBios::loop(); }

I get the following errors on compile:

In file included from C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/DcsBios.h:130, from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch800786\MasterCaution.ino:6: C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h: In member function 'void DcsBios::RotarySwitchT<pollIntervalMs, stepsPerDetent>::pollInput()': C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h:48:54: error: no matching function for call to 'min(int, signed char&)' 48 | switchValue = min(switchValue+1, maxSwichValue); | ^ In file included from c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\algorithm:62, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring_constants.h:26, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring.h:34, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/Arduino.h:36, from sketch\MasterCaution.ino.cpp:1: c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)' 3474 | min(initializer_list<_Tp> l, _Compare __comp) | ^~~ c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algo.h:3474:5: note: template argument deduction/substitution failed: In file included from C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/DcsBios.h:130, from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_800786\MasterCaution.ino:6: C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h:48:54: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 48 | switchValue = min(switchValue+1, maxSwichValue_); | ^ In file included from c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\algorithm:62, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring_constants.h:26, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring.h:34, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/Arduino.h:36, from sketch\MasterCaution.ino.cpp:1: c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algo.h:3468:5: note: candidate: 'template constexpr _Tp std::min(std::initializer_list<_Tp>)' 3468 | min(initializer_list<_Tp> l) | ^~~ c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algo.h:3468:5: note: template argument deduction/substitution failed: In file included from C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/DcsBios.h:130, from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_800786\MasterCaution.ino:6: C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h:48:54: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 48 | switchValue = min(switchValue+1, maxSwichValue_); | ^ In file included from c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\algorithm:61, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring_constants.h:26, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring.h:34, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/Arduino.h:36, from sketch\MasterCaution.ino.cpp:1: c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 278 | min(const _Tp& a, const _Tp& __b, _Compare comp) | ^~~ c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algobase.h:278:5: note: template argument deduction/substitution failed: In file included from C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/DcsBios.h:130, from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_800786\MasterCaution.ino:6: C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h:48:54: note: deduced conflicting types for parameter 'const Tp' ('int' and 'signed char') 48 | switchValue = min(switchValue+1, maxSwichValue); | ^ In file included from c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\algorithm:61, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring_constants.h:26, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/wiring.h:34, from C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\cores\arduino/Arduino.h:36, from sketch\MasterCaution.ino.cpp:1: c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algobase.h:230:5: note: candidate: 'template constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ c:\users\peter\appdata\local\arduino15\packages\stmicroelectronics\tools\xpack-arm-none-eabi-gcc\10.2.1-1.1\arm-none-eabi\include\c++\10.2.1\bits\stl_algobase.h:230:5: note: template argument deduction/substitution failed: In file included from C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/DcsBios.h:130, from C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_800786\MasterCaution.ino:6: C:\Users\Peter\Documents\Arduino\libraries\dcs-bios-arduino-library-0.3.6\src/internal/RotarySwitch.h:48:54: note: deduced conflicting types for parameter 'const Tp' ('int' and 'signed char') 48 | switchValue = min(switchValue+1, maxSwichValue); | ^ Multiple libraries were found for "Servo.h" Used: C:\Users\Peter\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.1.0\libraries\Servo Not used: C:\Program Files (x86)\Arduino\libraries\Servo exit status 1 Error compiling for board Generic STM32F1 series.

talbotmcinnis commented 2 years ago

I think this will be fixed on master as of a few days ago. Can you try to pull that down?

speedbird5 commented 2 years ago

Hi, I don't know what you mean.. Sorry. Are you referring to the Arduino library ? Can you send me a link ? For FP DCS-BIOS, I am using the DCS Beta version which is in the Master I think. I used your Arduino library from https://github.com/talbotmcinnis/dcs-bios-arduino-library/releases/download/0.3.6/dcs-bios-arduino-library-0.3.6.zip. Thanks.

talbotmcinnis commented 2 years ago

https://github.com/talbotmcinnis/dcs-bios-arduino-library/tree/master/src

Download the code from that link, and place it in your documents/arduino/library/dcs-bios... (make sure the files overwrite existing ones to know you are in the right place).

Alternatively I can work on making a new release zip but probably not able until the weekend.

speedbird5 commented 2 years ago

Thanks. I will try that tomorrow when I can and get back to you.

speedbird5 commented 2 years ago

Hi, that worked perfectly for compile and upload.....Thanks.

However, when I use the connect-serial-port.cmd I cannot send switch commands to the aircraft, but it does work with LED light status.

SOCAT is properly installed and it has access through the firewall. I have even turned the firewall off but it makes no difference.

I have also tried to run it with administrator privileges but that results in a "cannot find the path specified" error (see below).

So, it seems that I can't send commands to the sim but the sim can send led light status info back to the board (I'm using the built-in led to test).

Now, here is the really weird part: When I use the DCS-BIOS Hub executable to connect to the sim, everything works !!! Any idea why this may be so ?

Screenshot 2021-11-11 193924

speedbird5 commented 2 years ago

Hi Talbot, have you had a chance to consider this problem re connection?

talbotmcinnis commented 2 years ago

Hey. Very sorry for ghosting you for so long. Just making sure I understand you: It sounds like communication from DCS to your board works. You are saying an LED on your board reacts to DCS? But a switch on the board does not cause a change in DCS?

I'd start by confirming the serial port can receive. If you upload a sketch and use the arduino serial monitor (or any serial terminal program), you should be able to toggle the switch and see a human readable line every time the switch state changes.

Next I'd be curious to know if the Chrome Controls Ref works. You can launch the controls ref, then run DCS and try issuing commands from the control ref and see if they have an effect in DCS. If not, review your export.lua installation and specifically the files that should be copied along with it.

In DCS review control bindings for the control you are testing to make sure its not bound to a joystick button that is holding the state in DCS.

You mentioned firewall... are you sending this between PCs or is DCS running on the same PC that the microcontroller is connected to?

Let me know and I'll try to get back to you faster next time!!

speedbird5 commented 2 years ago

Thanks for replying Talbot.

It sounds like communication from DCS to your board works. You are saying an LED on your board reacts to DCS? But a switch on the board does not cause a change in DCS?

Yes, using connect-serial-port.cmd , that is correct. If the Master caution in the cockpit illuminates, the led on my board illuminates. But when I use a switch on my board, it does not move the cockpit switch. However, when I use the DCS-BIOS Hub executable to connect to the sim, everything works flawlessly.

If you upload a sketch and use the arduino serial monitor (or any serial terminal program), you should be able to toggle the switch and see a human readable line every time the switch state changes.

I uploaded my sketch and the serial monitor showed: ICP_AG_MODE_BTN TOGGLE every time I flicked the switch.

Next I'd be curious to know if the Chrome Controls Ref works. You can launch the controls ref, then run DCS and try issuing commands from the control ref and see if they have an effect in DCS. If not, review your export.lua installation and specifically the files that should be copied along with it.

Chrome Controls Ref works fine with connect-serial-port.cmd. From Chrome Controls Ref, I can send switch commands to DCS and the switches respond every time. Conversely, every time I flicked a switch in DCS, Chrome Controls reflected the change, My Export.lua file has the following contents: dofile(lfs.writedir()..[[Scripts\DCS-BIOS\BIOS.lua]])

I am using the Scripts folder from this link: https://github.com/DCSFlightpanels/dcs-bios/archive/refs/heads/master-/-DCS-Beta.zip I am on DCS Open Beta.

I can confirm in the CMD window I am getting a data stream. See attached image.

In DCS review control bindings for the control you are testing to make sure its not bound to a joystick button that is holding the state in DCS.

I have no controllers attached during testing with DCS BIOS. At this stage I am just testing on the ground in the F-16.

You mentioned firewall... are you sending this between PCs or is DCS running on the same PC that the microcontroller is connected to?

DCS is running on the same PC that the microcontroller is connected to. This is not a networked situation.

Why would it work flawlessly with the HUB executable and not the connect-serial-port.cmd ?

I know I can use the HUB as a work-around but long term that may cease to function as that project is dead. Any chance of FlightPanels getting the rights to the HUB code and bundling that in ? At least it will then be maintained.

Regards, Pete

Screenshot 2021-11-18 185320

talbotmcinnis commented 2 years ago

Great report. It sounds like you have done everything right. My specialty pretty much ends at the microcontrollers so you might need to raise the question back in discord with the dcs-bios side of things. I have no theories about why hub would work I haven't used it in years. The original dev ?Ian? Has been pretty unhelpful about releasing or supporting it afaik but I have never asked him personally.

One idea might be to use portman or performance monitor to check for any conflicting processes using the dcs-bios ports. You'll see the required ports if you open the script file pointed to by your export lua. One for out, one for in. Or maybe increment both sides (socat command and the lua) by the same amount and retry?

speedbird5 commented 2 years ago

Thanks. I am on Windows 11. Could that be an issue ?

I’ll try and work out the Portman thing but I think it’s beyond my pay grade.

Can you send me the link for the discord server ?

talbotmcinnis commented 2 years ago

Portman is beyond what you need actually. Window resource monitor will show you what you need: http://support.moonpoint.com/os/windows/network/monitoring/resmon/NIS/

Just look for anything on port 7778.

speedbird5 commented 2 years ago

Could Windows 11 be the issue ?

talbotmcinnis commented 2 years ago

Interesting. Definitely possible. Have you tried running socat elevated?

Once socat is running you should definitely see it in listening on 7778. If not, then something has blocked it.

On Nov 19, 2021, at 08:23, speedbird5 @.***> wrote:

 Could Windows 11 be the issue ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

talbotmcinnis commented 2 years ago

Sorry, socot sends to 7778 so it’ll be some dcs-bios or dcs itself listening on port 7778.

On Nov 19, 2021, at 08:23, speedbird5 @.***> wrote:

 Could Windows 11 be the issue ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

speedbird5 commented 2 years ago

Yes I have tried running socat elevated and I get an error. See my earlier post and the error I get.

speedbird5 commented 2 years ago

Hi Talbot, if you have access to a Windows 11 machine, is it possible for you to test ? I'm trying to work out if it specific to my machine or Windows 11 in general. thanks

maciekish commented 1 year ago

Hi, sorry for resurrecting this, is RS485 supported? Its complaining about <libmaple/usart.h>