File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ typedef struct user_port_t {
9999// downgrade, if necessary.
100100typedef struct __attribute__((aligned (sizeof (void * )))) user_port_init_args_t {
101101 int api_version ;
102+
103+ // Callback for setting an error message from the plugin
104+ // Errors longer than 256 chars (including null) will be truncated
105+ void (* set_error )(char const * );
102106} user_port_init_args_t ;
103107
104108// Populates the provided [user_port_t *]. If any of [read], [write] or [step] is NULL, it
Original file line number Diff line number Diff line change @@ -347,6 +347,18 @@ static user_port_init_t user_port_init = NULL;
347347
348348static user_port_t user_port ;
349349
350+ static char last_user_port_error [256 ] = "OK" ;
351+
352+ static void
353+ set_user_port_error (char const * err )
354+ {
355+ if (err ) {
356+ strncpy (sizeof (last_user_port_error ), last_user_port_error , err );
357+ } else {
358+ last_user_port_error = "OK" ;
359+ }
360+ }
361+
350362void
351363via2_init (char const * user_peripheral_plugin_path )
352364{
@@ -371,7 +383,7 @@ via2_init(char const *user_peripheral_plugin_path)
371383 .api_version = X16_USER_PORT_API_VERSION ,
372384 };
373385 if (user_port_init (& init_args , & user_port ) < 0 ) {
374- fprintf (stderr , "error initializing user peripheral\n" );
386+ fprintf (stderr , "error initializing user peripheral: %s \n" , last_user_port_error );
375387 error = true;
376388 }
377389 else if (user_port .api_version != X16_USER_PORT_API_VERSION ) {
You can’t perform that action at this time.
0 commit comments