Skip to content

Commit

Permalink
Merge pull request #82 from bltzr/API-update
Browse files Browse the repository at this point in the history
updating API file for previous merged pull request
  • Loading branch information
adrianfreed committed May 24, 2018
2 parents 1eedba5 + b71f4b6 commit ea9926c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions API.md
Expand Up @@ -104,23 +104,36 @@ Returns the boolean at the given position

Returns the double at the given position. NOTE: double is not supported by most Arduino platforms. This will fail silently if double is not supported.

### `int getString(char * strBuffer)`

### `int getString(int position, char * str, int length)`
Copy the string’s characters into the `strBuffer’, without any safetcheck’.
Returns the number of copied characters.

Copy `length` number of characters from the given position into the `str` buffer. Returns the number of copied characters.
### `int getString(char * strBuffer, int length)`

Copy the string’s characters into the `strBuffer’, after checking that this doesn’t exceed the buffer’s ‘length’.
Returns the number of copied characters.

### `int getString(char * strBuffer, int length, int offset, int size)`

Copy `size` number of characters from the given ‘offset’ into the `strBuffer’, after checking that this doesn’t exceed the buffer’s ‘length’. Returns the number of copied characters.

```C++
char str[8];
//fill str with 8 characters from the 0th datum
msg.getString(0, str, 8);
msg.getString(str, 8, 0, 8);
```

### `int getBlob(uint8_t * blobBuffer)`

### `int getBlob(int position, uint8_t * blob, int length)`
Directly copy the blob’s bytes into the `blob` buffer (without safety-check).
Returns the number of bytes from the blob.

Copy `length` number of bytes from the given position into the `blob` buffer. Returns the number of copied bytes.

### `int getBlob(uint8_t * blobBuffer, int length, int offset, int size)`

Copy ‘size’ bytes from the blob, starting from ‘offset’, into the given `blobBuffer’, if the size doesn’t exceed the buffer’s (or the blob’s) ‘length’.
Returns the number of bytes copied from the blob.

### `char getType(int position)`

Expand Down
2 changes: 1 addition & 1 deletion OSCData.cpp 100755 → 100644
Expand Up @@ -255,7 +255,7 @@ int OSCData::getString(char * strBuffer, int length){
}
}

// Here we can get only a part of the blob
// Here we can get only a part of the string
int OSCData::getString(char * strBuffer, int length, int offset, int size){
if (type == 's' && size <= bytes && size <= length){
strncpy(strBuffer, data.s + offset, size);
Expand Down

0 comments on commit ea9926c

Please sign in to comment.