Private
Public Access
2
0

imraa: split imraa up into imraa_io and imraa_lock

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-09-27 13:07:45 +01:00
parent c69d1884c9
commit 3971d27f8a
8 changed files with 318 additions and 171 deletions

View File

@@ -41,6 +41,7 @@
#include <mraa/pwm.h>
#include <mraa_internal.h>
#include <imraa_lock.h>
const char*
imraa_list_serialport()
@@ -182,35 +183,6 @@ imraa_flash_101(const char* bin_path, const char* bin_file_name, const char* tty
return 0;
}
void
imraa_write_lockfile(const char* lock_file_location, const char* serialport)
{
FILE* fh;
char str[10];
json_object* platform1 = json_object_new_object();
snprintf(str, 10, "%d", MRAA_NULL_PLATFORM);
json_object_object_add(platform1, "id", json_object_new_string(str));
json_object* platform2 = json_object_new_object();
snprintf(str, 10, "%d", MRAA_GENERIC_FIRMATA);
json_object_object_add(platform2, "id", json_object_new_string(str));
json_object_object_add(platform2, "uart", json_object_new_string(serialport));
json_object* platfroms = json_object_new_array();
json_object_array_add(platfroms, platform1);
json_object_array_add(platfroms, platform2);
json_object* lock_file = json_object_new_object();
json_object_object_add(lock_file, "Platform", platfroms);
fh = fopen(lock_file_location, "w");
if (fh != NULL) {
fputs(json_object_to_json_string_ext(lock_file, JSON_C_TO_STRING_PRETTY), fh);
fclose(fh);
} else {
fprintf(stderr, "can't write to lock file\n");
}
json_object_put(lock_file);
}
void
imraa_handle_subplatform(struct json_object* jobj, bool force_update)
{