2
votes

I'm lately getting this weird error in Simulink that I can't find any information on.

Matlab version: 2018a OS: Windows 10

Error

gpio_in.c is the code for an s-function that was generated using the s-function builder. My own code is located in the associated wrapper file gpio_in_wrapper.c. The s-function builder is set to save code only and not to build it. I use this file for hardware interaction in later deployment via the Simulink coder.

Whenever I try to start the simulation, Simulink presents the above error to me and I don't have a clue what the problem could be. It looks to me like D: is the beginning of a file path, especially if you consider the warning above which says \D and is probably the beginning of the models directory which is D:\Dateien\Git_Repositories\BMaS_Neu\Simulink.

Contents of gpio_in_wrapper.c as suggested by UnbearableLightness

/*
 * Include Files
 *
 */
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif

/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <gpio.h>
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 1
#define y_width 1

/*
 * Create external references here.  
 *
 */
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */

/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */

/*
 * Output function
 *
 */
void gpio_in_Outputs_wrapper(const int32_T *port_popupvalue,
                             const int32_T *pin_number,
                             boolean_T     *gpio_in)
{
    /* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
    if (*port_popupvalue == 1) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOA, (1 << *pin_number));
    } else if (*port_popupvalue == 2) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOB, (1 << *pin_number));
    } else if (*port_popupvalue == 3) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOC, (1 << *pin_number));
    } else if (*port_popupvalue == 4) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOD, (1 << *pin_number));
    } else if (*port_popupvalue == 5) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOE, (1 << *pin_number));
    } else if (*port_popupvalue == 6) {
        *gpio_in = HAL_GPIO_ReadPin(GPIOF, (1 << *pin_number));
    } else if (*port_popupvalue == 7) {
       *gpio_in = HAL_GPIO_ReadPin(GPIOG, (1 << *pin_number));
    } else if (*port_popupvalue == 8) {
       *gpio_in = HAL_GPIO_ReadPin(GPIOH, (1 << *pin_number));
    } else if (*port_popupvalue == 9) {
       *gpio_in = HAL_GPIO_ReadPin(GPIOI, (1 << *pin_number));
    }
    /* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}

I'd appreciate every hint of yours.

1
Share your code. The error is telling you \D is not valid for the function sprintf which your code is probably using. - Paolo
If you can't share your code do dbstop in sprintf and try to find a call to sprintf that's passing something with \D in the format specifier. If it's in MathWorks code, please report it via MathWorks technical support - Ryan Livingston
@UnbearableLightness Which files would be helpful to you? The respective c source files? It's a student project so I can share anything you'd like. - Simon
@Simon The source file of interest is gpio_in_wrapper.c - Paolo
@UnbearableLightness Added it to the question. - Simon

1 Answers

1
votes

I think what is happening is that your code is accessing something from a path on D drive. For example, if the path name is 'D:\Somedirectory\Somefile', sometimes it treats '\S' as an escape sequence and throws an error. The solution for this would be replacing '\' with '\\', i.e, 'D:\\Somedirectory\\Somefile'.

According to the error it has escaped '\D' which means that the first letter of the directory or filename starts with 'D'.

As Cris Luengo mentioned in his comment, you should check the m-file, which is were you might find the part of code using a path.
Also is there any error text on the command window?