0

I have written a C++ code to program STB1132-25 BLE module by calling/executing BlueNRG-X_Flasher_Launcher.exe through the c standard function system(const char*). I have the same setup for ST-LINK_CLI.exe to program STM32 controllers. I am passing correct arguments to both programming tools. I can successfully flash both the BLE module and stm32 controllers. But when some error occurred in X_Flasher_Launcher.exe, I always get a return code 0 and my code interprets it as a successful operation. I am not facing the same problem with ST-LINK_CLI.exe. when some error occurs, it returns =>1 and my code interprets it as an error.

For example, if ST-LINK/V2 programmer is not connected or target is not connected then ST-LINK_CLI.exe fails and returns 1 but BlueNRG-X_Flasher_Launcher.exe also fails, and return 0. basically, irrespective of failure or success it always returns 0.

Could anyone suggest to me how should I resolve this issue?

I know system(const char*) is not the best way to call an external program. but I just want to have a solution that works and later I will implement Windows' solution to call external programs (for e.g. createProcess).

OS: Windows 10 programming software tool: BlueNRG-X_Flasher_Launcher.exe v4.1.0, ST-LINK_CLI.exe v3.1.0

Edit: I have specified the wrong return codes. I updated the post with correct values.

TheThirdFriend
  • 59
  • 1
  • 1
  • 7
  • If the program does not return a proper error value there's not much you can do. Find a different program or file a bug with the authors of the program you're using. – Retired Ninja Jul 06 '21 at 08:18
  • non-zero value returned from main() on Windows _means_ either some error or some app-specific code. But what actually is returned by `system` depends on multiple things, this might be not even the execution result. Note, system doesn't execute the program. It executes the shell – Swift - Friday Pie Jul 06 '21 at 08:20
  • as per the BLE flasher, I should receive >0 if an error occurs in it. refer to section 4.1.5 of https://www.st.com/resource/en/user_manual/dm00326881-bluenrg1-stlink-utility-software-description-stmicroelectronics.pdf – TheThirdFriend Jul 06 '21 at 08:40

0 Answers0