ARMmbed / ATParser

Parser for AT commands and similar protocols.
36 stars 27 forks source link

read() and write() do not behave as documented #2

Open mfiore02 opened 7 years ago

mfiore02 commented 7 years ago

read() and write() do not behave as documented in ATParser.h.

/**
* Write an array of bytes to the underlying stream
*
* @param data the array of bytes to write
* @param size number of bytes to write
* @return number of bytes written or -1 on failure
*/
int write(const char *data, int size);

/**
* Read an array of bytes from the underlying stream
*
* @param data the destination for the read bytes
* @param size number of bytes to read
* @return number of bytes read or -1 on failure
*/
int read(char *data, int size);

Existing implementation will error out if bytes read/written do not exactly match size parameter.

geky commented 7 years ago

Hi @mfiore02, thanks for the issue andpr to fix this. One of us should have responded a long time ago.

Unfortunately, this repo is used in quite a few places, so backwards compatibility is very important at the moment. I agree that the behaviour isn't intuitive and should be changed to match the API that is normally expected (and even documented), but changing this API may break quite a few dependencies.

So we've been hesitant to merge this change until we are in a place where we can break a few APIs. I haven't checked, but this may have already ended up in the ATCmdParser fork, and should be included in any new majore revisions of the driver.