Skip to content

Commit

Permalink
detect core load errors and use them to populate the new LoadErrorCon…
Browse files Browse the repository at this point in the history
…troller interface in the ui, lets us know when something bad happens (although this isnt as important here as it is in android since we can just ctrl+shift+k, but oh well, good to test here first to make sure it all works)
  • Loading branch information
orthecreedence committed Aug 19, 2018
1 parent f8944bc commit bacd255
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
7 changes: 7 additions & 0 deletions lib/app/core-adapter/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

if(!Node || !Node.core) return;
var TurtlCore = Node.core.TurtlCore;
var core_load_error = TurtlCore.get_load_error();
if(core_load_error) {
setTimeout(function() {
new LoadErrorController({error: core_load_error});
}, 200);
return;
}

var res = TurtlCore.init();
if(res !== 0) {
Expand Down
25 changes: 17 additions & 8 deletions lib/node/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ const ref = require('ref');
const ffi = require('ffi');
const path = require('path');

const dll_loc = path.join(__dirname, '..', '..', 'build', 'turtl_core');
var TurtlCore = ffi.Library(dll_loc, {
'turtlc_start': ['int32', ['string', 'uint8']],
'turtlc_send': ['int32', ['pointer', 'size_t']],
'turtlc_recv': ['pointer', ['uint8', 'string', 'size_t*']],
'turtlc_recv_event': ['pointer', ['uint8', 'size_t*']],
'turtlc_free': ['int32', ['pointer', 'size_t']],
});
var load_error = null;
try {
const dll_loc = path.join(__dirname, '..', '..', 'build', 'turtl_core');
var TurtlCore = ffi.Library(dll_loc, {
'turtlc_start': ['int32', ['string', 'uint8']],
'turtlc_send': ['int32', ['pointer', 'size_t']],
'turtlc_recv': ['pointer', ['uint8', 'string', 'size_t*']],
'turtlc_recv_event': ['pointer', ['uint8', 'size_t*']],
'turtlc_free': ['int32', ['pointer', 'size_t']],
});
} catch(err) {
load_error = err;
}

exports.get_load_error = function() {
return load_error;
};

exports.init = function(userconfig) {
userconfig || (userconfig = {});
Expand Down

0 comments on commit bacd255

Please sign in to comment.