Skip to content

Commit

Permalink
Merge pull request #38 from katie-snow/release_1_0
Browse files Browse the repository at this point in the history
Release 1.0
  • Loading branch information
katie-snow authored Nov 3, 2016
2 parents b6414cb + 73c7a20 commit 3318737
Show file tree
Hide file tree
Showing 35 changed files with 1,072 additions and 370 deletions.
42 changes: 0 additions & 42 deletions .autotools

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.dylib

# Executables
umtool
*.exe
*.out
*.app
Expand Down Expand Up @@ -57,6 +58,7 @@ config.guess
config.sub
depcomp
ltmain.sh
.autotools
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
Expand Down
1 change: 1 addition & 0 deletions 21-ultimarc.rules
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="05
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0502", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0503", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="0504", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1200", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1401", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1402", MODE:="666"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="1403", MODE:="666"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This library and command line utility support 2012 through 2015 boards. If you

#### Required Libraries
To build this tool the following libraries need to be install on your system.
* json-c (0.11),
* libusb-dev (1.0.18)
* json-c (0.11), <a href='https://github.com/json-c/json-c/wiki'>site</a>
* libusb-1.0 (1.0.18), <a href='http://libusb.info'>site</a>
* libtool

#### UDEV Rule:
Expand All @@ -28,7 +28,7 @@ If you need extra debug statements for the IPac boards then run the following
* make

The executable will be in src/umtool directory and named umtool.out.
* ./umtool.out ipac2.json
* ./umtool ipac2.json

#### Donations:
<a href='https://pledgie.com/campaigns/26846'><img alt='Click here to lend your support to: Ultimarc-Linux and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/26846.png?skin_name=chrome' border='0' ></a>
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(Ultimarc-linux, 0.1)
AC_INIT(Ultimarc-linux, 1.0)

AC_CANONICAL_HOST
AM_INIT_AUTOMAKE()
Expand Down Expand Up @@ -29,7 +29,7 @@ CPPFLAGS="-I$KERNEL_HEADERS_DIR/include"
AX_PKG_CHECK_MODULES([JSON], [], [json-c >= 0.11])
AX_PKG_CHECK_MODULES([LIBUSB], [], [libusb-1.0 >= 1.0.18])

AC_SUBST([ULTIMARC_LIB_VERSION], [0.1])
AC_SUBST([ULTIMARC_LIB_VERSION], [1.0])

AC_CONFIG_FILES([Makefile
src/libs/Makefile
Expand Down
7 changes: 4 additions & 3 deletions src/libs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ AM_CFLAGS = $(JSON_CFLAGS) $(LIBUSB_CFLAGS)
AM_LDFLAGS = $(JSON_LIBS) $(LIBUSB_LIBS)


lib_LTLIBRARIES = libultimarc-0.1.la
libultimarc_0_1_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c
lib_LTLIBRARIES = libultimarc.la
libultimarc_la_SOURCES = ultimarc.c ipac.c ultistik.c pacLED.c common.c pacdrive.c ipacultimate.c ipacseries.c ulboard.c usbbutton.c ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h usbbutton.h
libultimarc_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0

otherincludedir = $(includedir)/ultimarc
otherinclude_HEADERS = ultimarc.h ipac.h ultistik.h pacLED.h common.h pacdrive.h ipacultimate.h dbg.h ipacseries.h
otherinclude_HEADERS = ultimarc.h ulboard.h

4 changes: 2 additions & 2 deletions src/libs/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#define clean_errno() (errno == 0 ? "None" : strerror(errno))

#define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
#define log_err(M, ...) fprintf(stderr, "[ERROR] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)

#define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
#define log_warn(M, ...) fprintf(stderr, "[WARN] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)

#define log_info(M, ...) fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)

Expand Down
65 changes: 29 additions & 36 deletions src/libs/ipac.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,37 @@
#include <libusb-1.0/libusb.h>

/* Local */
#include "ulboard.h"
#include "common.h"
#include "ipac.h"
#include "ipacseries.h"
#include "dbg.h"

struct ipac pIPAC;

bool isIPACConfig (const char* prodStr, int version, json_object* jobj)
bool isIPACConfig (json_object* jobj, ulboard* board)
{
bool isBoardCfg = false;

pIPAC.version = version;
pIPAC.ipac2 = (strcmp(prodStr, IPAC_STR_2) == 0);
pIPAC.minipac = (strcmp(prodStr, IPAC_STR_M) == 0);
pIPAC.ipac4 = (strcmp(prodStr, IPAC_STR_4) == 0);
pIPAC.jpac = (strcmp(prodStr, JPAC_STR) == 0);

if (pIPAC.ipac2)
if (board->type == ulboard_type_ipac2)
{
isBoardCfg = validateIPACData(jobj, 32);
isBoardCfg = validateIPACData(jobj, 32, board);
}
else if (pIPAC.ipac4)
else if (board->type == ulboard_type_ipac4)
{
isBoardCfg = validateIPAC4Data(jobj);
isBoardCfg = validateIPAC4Data(jobj, board);
}
else if (pIPAC.minipac)
else if (board->type == ulboard_type_minipac)
{
isBoardCfg = validateIPACData(jobj, 32);
isBoardCfg = validateIPACData(jobj, 32, board);
}
else if (pIPAC.jpac)
else if (board->type == ulboard_type_jpac)
{
isBoardCfg = validateIPACData(jobj, 30);
isBoardCfg = validateIPACData(jobj, 30, board);
}

return isBoardCfg;
}

bool validateIPACData(json_object* jobj, int size)
bool validateIPACData(json_object* jobj, int size, ulboard* board)
{
bool valid = true;
json_object* tmp = NULL;
Expand Down Expand Up @@ -119,12 +112,12 @@ bool validateIPACData(json_object* jobj, int size)
}
}

valid = validateIPACMacros(jobj, valid);
valid = validateIPACMacros(jobj, valid, board);

return valid;
}

bool validateIPAC4Data (json_object* jobj)
bool validateIPAC4Data (json_object* jobj, ulboard* board)
{
bool valid = true;

Expand Down Expand Up @@ -203,12 +196,12 @@ bool validateIPAC4Data (json_object* jobj)
}
}

valid = validateIPACMacros(jobj, valid);
valid = validateIPACMacros(jobj, valid, board);

return valid;
}

bool validateIPACMacros(json_object* jobj, bool validState)
bool validateIPACMacros(json_object* jobj, bool validState, ulboard* board)
{
bool valid = validState;

Expand Down Expand Up @@ -253,7 +246,7 @@ bool validateIPACMacros(json_object* jobj, bool validState)
}
else
{
if (pIPAC.version == 1)
if (board->version == ulboard_version_pre2015)
{
if (json_object_array_length(macro) != maxKeyCount)
{
Expand Down Expand Up @@ -289,12 +282,12 @@ bool validateIPACMacros(json_object* jobj, bool validState)
}
}

if ((pIPAC.version == 1) && (macroCount > maxMacroCount))
if ((board->version == ulboard_version_pre2015) && (macroCount > maxMacroCount))
{
log_err("The number of macros defined is '%i'. 4 macro entries are allowed.", macroCount);
valid = false;
}
else if (pIPAC.version == 2)
else if (board->version == ulboard_version_2015)
{
if (macroCount2015 > maxMacroCount2015)
{
Expand All @@ -314,16 +307,16 @@ bool validateIPACMacros(json_object* jobj, bool validState)
return valid;
}

bool updateBoardIPAC (json_object *jobj)
bool updateBoardIPAC (json_object *jobj, ulboard *board)
{
bool result = false;
int bprod = 0;
unsigned char* barray = NULL;

switch (pIPAC.version)
switch (board->version)
{
case 1:
if (pIPAC.ipac2)
case ulboard_version_pre2015:
if (board->type == ulboard_type_ipac2)
{
log_info ("Updating IPAC2 board...");
barray = calloc(IPAC_SIZE_PRE_2015, sizeof(unsigned char));
Expand All @@ -338,7 +331,7 @@ bool updateBoardIPAC (json_object *jobj)
}
}

if (pIPAC.minipac)
if (board->type == ulboard_type_minipac)
{
log_info ("Updating MinIPAC board...");
barray = calloc(IPAC_SIZE_PRE_2015, sizeof(unsigned char));
Expand All @@ -353,7 +346,7 @@ bool updateBoardIPAC (json_object *jobj)
}
}

if (pIPAC.ipac4)
if (board->type == ulboard_type_ipac4)
{
log_info ("Updating IPAC4 board...");
barray = calloc((IPAC_SIZE_PRE_2015 * 2), sizeof(unsigned char));
Expand All @@ -370,32 +363,32 @@ bool updateBoardIPAC (json_object *jobj)
}
break;

case 2:
case ulboard_version_2015:
barray = calloc(IPACSERIES_SIZE, sizeof(unsigned char));

if (barray != NULL)
{
if (pIPAC.ipac2)
if (board->type == ulboard_type_ipac2)
{
log_info ("Updating IPAC2 board...");
bprod = IPAC_2_PRODUCT;
update2015IPAC2Board(jobj, barray);
}

else if (pIPAC.minipac)
else if (board->type == ulboard_type_minipac)
{
log_info ("Updating MinIPAC board...");
bprod = IPAC_M_PRODUCT;
update2015MinIPACBoard(jobj, barray);
}

else if (pIPAC.ipac4)
else if (board->type == ulboard_type_ipac4)
{
log_info ("Updating IPAC4 board...");
bprod = IPAC_4_PRODUCT;
update2015IPAC4Board(jobj, barray);
}
else if (pIPAC.jpac)
else if (board->type == ulboard_type_jpac)
{
log_info ("Updating JPAC board...");
bprod = JPAC_PRODUCT;
Expand Down
26 changes: 6 additions & 20 deletions src/libs/ipac.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
extern "C" {
#endif

/* Required items in the json file for IPAC2, MINIPAC, IPAC4 and JPAC cards */
#define IPAC_STR_2 "ipac2"
#define IPAC_STR_M "minipac"
#define IPAC_STR_4 "ipac4"
#define JPAC_STR "jpac"

/* Required items for writing out through the USB port */
#define IPAC_VENDOR_PRE_2015 0xD208
#define IPAC_VENDOR_2015 0xD209
Expand All @@ -35,19 +29,11 @@ extern "C" {
#define IPAC_INTERFACE 2

typedef struct json_object json_object;
typedef struct ulboard ulboard;

struct ipac
{
int version;
bool minipac;
bool ipac2;
bool ipac4;
bool jpac;
};

bool isIPACConfig (const char* prodStr, int version, json_object* jobj);
bool validateIPACData(json_object* jobj, int size);
bool validateIPAC4Data(json_object* jobj);
bool isIPACConfig (json_object* jobj, ulboard* board);
bool validateIPACData(json_object* jobj, int size, ulboard* board);
bool validateIPAC4Data(json_object* jobj, ulboard* board);

/*
* macros are optional.
Expand All @@ -59,12 +45,12 @@ bool validateIPAC4Data(json_object* jobj);
* limit of 85 bytes for the complete macro group (2015 boards)
*
*/
bool validateIPACMacros(json_object* jobj, bool valid);
bool validateIPACMacros(json_object* jobj, bool valid, ulboard* board);

/*
* Writes the data out to the board.
*/
bool updateBoardIPAC (json_object *jobj);
bool updateBoardIPAC (json_object *jobj, ulboard* board);

void updatePre2015IPAC2Board (json_object *jobj, unsigned char* barray);

Expand Down
Loading

0 comments on commit 3318737

Please sign in to comment.