Skip to content

Commit

Permalink
check err status for rust (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 authored Nov 16, 2023
1 parent 31f4c3c commit 9f84011
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- '.github/workflows/rust.yml'
- 'binding/rust/**'
- 'binding/rust/**/*.rs'
- '!binding/rust/README.md'
- 'lib/beaglebone/**'
- 'lib/common/**'
Expand All @@ -28,6 +29,7 @@ on:
paths:
- '.github/workflows/rust.yml'
- 'binding/rust/**'
- 'binding/rust/**/*.rs'
- '!binding/rust/README.md'
- 'lib/beaglebone/**'
- 'lib/common/**'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ For more information about Go demos go to [demo/go](./demo/go).

### Unity Demos

To run the Rhino Unity demo, import the [Rhino Unity package](./binding/unity/rhino-2.1.4.unitypackage) into your project, open the RhinoDemo scene and hit play. To run on other platforms or in the player, go to _File > Build Settings_, choose your platform and hit the `Build and Run` button.
To run the Rhino Unity demo, import the [Rhino Unity package](./binding/unity/rhino-3.0.0.unitypackage) into your project, open the RhinoDemo scene and hit play. To run on other platforms or in the player, go to _File > Build Settings_, choose your platform and hit the `Build and Run` button.
/
To browse the demo source go to [demo/unity](./demo/unity).

Expand Down Expand Up @@ -766,7 +766,7 @@ rhino.Delete()

### Unity

Import the [Rhino Unity Package](./binding/unity/rhino-2.1.4.unitypackage) into your Unity project.
Import the [Rhino Unity Package](./binding/unity/rhino-3.0.0.unitypackage) into your Unity project.

The SDK provides two APIs:

Expand Down
11 changes: 9 additions & 2 deletions binding/rust/src/rhino.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type PvRhinoVersionFn = unsafe extern "C" fn() -> *mut c_char;
type PvRhinoFrameLengthFn = unsafe extern "C" fn() -> i32;
type PvSampleRateFn = unsafe extern "C" fn() -> i32;
type PvGetErrorStackFn =
unsafe extern "C" fn(message_stack: *mut *mut *mut c_char, message_stack_depth: *mut i32);
unsafe extern "C" fn(message_stack: *mut *mut *mut c_char, message_stack_depth: *mut i32)-> PvStatus;
type PvFreeErrorStackFn = unsafe extern "C" fn(message_stack: *mut *mut c_char);
type PvSetSdkFn = unsafe extern "C" fn(sdk: *const c_char);

Expand Down Expand Up @@ -295,11 +295,18 @@ fn check_fn_call_status(
let mut message_stack_ptr_ptr = addr_of_mut!(message_stack_ptr);

let mut message_stack_depth: i32 = 0;
(vtable.pv_get_error_stack)(
let err_status = (vtable.pv_get_error_stack)(
addr_of_mut!(message_stack_ptr_ptr),
addr_of_mut!(message_stack_depth),
);

if err_status != PvStatus::SUCCESS {
return Err(RhinoError::new(
RhinoErrorStatus::LibraryError(err_status),
"Unable to get Rhino error state",
));
};

let mut message_stack = Vec::new();
for i in 0..message_stack_depth as usize {
let message = CStr::from_ptr(*message_stack_ptr_ptr.add(i));
Expand Down
10 changes: 4 additions & 6 deletions binding/unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ Rhino is:

## Compatibility

[Rhino unity package](./rhino-2.2.2.unitypackage) is for running Rhino on **Unity 2017.4+** on the following platforms:
[Rhino unity package](./rhino-3.0.0.unitypackage) is for running Rhino on **Unity 2017.4+** on the following platforms:

- Android 4.4+ (API 19+) (ARM only)
- iOS 9.0+
- Android 5.0+ (API 21+) (ARM only)
- iOS 13.0+
- Windows (x86_64)
- macOS (x86_64)
- Linux (x86_64)

For running Rhino on **macOS m1 (arm64)**, use the [Apple silicon](./rhino-2.2.2-Apple-silicon.unitypackage) version on **Unity 2021.2+**.

## Installation

The easiest way to install the Rhino Unity SDK is to import the [Rhino Unity Package](./rhino-2.2.2.unitypackage) into your Unity project by either dropping it into the Unity editor or going to _Assets>Import Package>Custom Package..._
The easiest way to install the Rhino Unity SDK is to import the [Rhino Unity Package](./rhino-3.0.0.unitypackage) into your Unity project by either dropping it into the Unity editor or going to _Assets>Import Package>Custom Package..._

**NOTE:** On macOS, the Rhino library may get flagged as having come from an unverified source if you've downloaded the `.unitypackage` directly from github. This should only come up when running your project in the Editor. To disable this warning, go to Security & Preferences and choose to allow pv_rhino.dylib to run.

Expand Down
2 changes: 1 addition & 1 deletion demo/unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Replace the `AccessKey` in [`RhinoDemo.cs`](RhinoDemo.cs) with the `AccessKey` o
private const string ACCESS_KEY = "${YOUR_ACCESS_KEY_HERE}"; // AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
```

The easiest way to run the demo is to simply import the [Rhino Unity package](../../binding/unity/rhino-2.1.4.unitypackage) into your project, open the RhinoDemo scene and hit play. To run on other platforms or in the player, go to _File > Build Settings_, choose your platform and hit the `Build and Run` button.
The easiest way to run the demo is to simply import the [Rhino Unity package](../../binding/unity/rhino-3.0.0.unitypackage) into your project, open the RhinoDemo scene and hit play. To run on other platforms or in the player, go to _File > Build Settings_, choose your platform and hit the `Build and Run` button.

Once the demo launches, press the `Start Listening` button, and you can say anything in the smart lighting context:

Expand Down

0 comments on commit 9f84011

Please sign in to comment.