Skip to content

Conversation

@alexandruCarp
Copy link

Fixes #31 .
As suggested, I tried to add a check for command's return:

if let Err(err) = S::command(DRIVER_NUM, command::WRITE, s.len() as u32, 0)
                .to_result::<(), ErrorCode>()
            {
                return Err(err);
            }

But that didn't solve the problem, and from the console capsule's code it seems like that command will never return an error:

1 => {
                        // putstr
                        let len = arg1;
                        self.send_new(appid, app, kernel_data, len)
                    }
fn send_new(
        &self,
        app_id: ProcessId,
        app: &mut App,
        kernel_data: &GrantKernelData,
        len: usize,
    ) -> Result<(), ErrorCode> {
        app.write_len = kernel_data
            .get_readonly_processbuffer(ro_allow::WRITE)
            .map_or(0, |write| write.len())
            .min(len);
        app.write_remaining = app.write_len;
        self.send(app_id, app, kernel_data);
        Ok(())
    }

I've also added a guard clause in the write function of the Console API:

        if s.len() == 0 {
            return Ok(());
        }

This solves the problem, and it seems right for the write function to do nothing at all if there isn't anything to be written.

@alexandruCarp
Copy link
Author

I found this note in the documentation of WRITE command:

Additional notes: A process may call this command with a write size of 0 to cancel a write transaction, if one is ongoing. Unless an error occurs, this will generate a write transaction completed event, regardless of whether or not a write transaction was already in progress.

However, it does not return an error and it does not generate an event (the process wouldn't remain yielded otherwise). Am I missing something?

@alexandruCarp
Copy link
Author

Posted issue tock/tock#3433.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console API - empty string bug

2 participants