1
0
mirror of https://github.com/raphnet/gc_n64_usb-v3 synced 2024-12-21 06:48:52 -05:00

Implement getVersion

This commit is contained in:
Raphael Assenat 2015-10-17 23:18:32 -04:00
parent 5c9fefd9f7
commit 6ce59a9477
3 changed files with 37 additions and 0 deletions

View File

@ -56,6 +56,29 @@ int gcn64lib_suspendPolling(gcn64_hdl_t hdl, unsigned char suspend)
return 0;
}
int gcn64lib_getVersion(gcn64_hdl_t hdl, char *dst, int dstmax)
{
unsigned char cmd[64];
int n;
if (dstmax <= 0)
return -1;
cmd[0] = RQ_GCN64_GET_VERSION;
n = gcn64_exchange(hdl, cmd, 2, cmd, sizeof(cmd));
if (n<0)
return n;
dst[0] = 0;
if (n > 1) {
strncpy(dst, (char*)cmd+1, n);
}
dst[dstmax-1] = 0;
return 0;
}
int gcn64lib_rawSiCommand(gcn64_hdl_t hdl, unsigned char channel, unsigned char *tx, unsigned char tx_len, unsigned char *rx, unsigned char max_rx)
{
unsigned char cmd[3 + tx_len];

View File

@ -7,6 +7,7 @@ int gcn64lib_suspendPolling(gcn64_hdl_t hdl, unsigned char suspend);
int gcn64lib_setConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *data, unsigned char len);
int gcn64lib_getConfig(gcn64_hdl_t hdl, unsigned char param, unsigned char *rx, unsigned char rx_max);
int gcn64lib_rawSiCommand(gcn64_hdl_t hdl, unsigned char channel, unsigned char *tx, unsigned char tx_len, unsigned char *rx, unsigned char max_rx);
int gcn64lib_getVersion(gcn64_hdl_t hdl, char *dst, int dstmax);
int gcn64lib_8bit_scan(gcn64_hdl_t hdl, unsigned char min, unsigned char max);
int gcn64lib_16bit_scan(gcn64_hdl_t hdl, unsigned short min, unsigned short max);

View File

@ -48,6 +48,7 @@ static void printUsage(void)
printf(" --nonstop Continue testing forever or until an error occurs.\n");
printf("\n");
printf("Configuration commands:\n");
printf(" --get_version Read adapter firmware version\n");
printf(" --set_serial serial Assign a new device serial number\n");
printf(" --get_serial Read serial from eeprom\n");
printf(" --set_poll_rate ms Set time between controller polls in milliseconds\n");
@ -112,6 +113,7 @@ static void printUsage(void)
#define OPT_GC_TO_N64_READ_MAPPING 320
#define OPT_GC_TO_N64_LOAD_MAPPING 321
#define OPT_GC_TO_N64_STORE_CURRENT_MAPPING 322
#define OPT_GET_VERSION 323
struct option longopts[] = {
{ "help", 0, NULL, 'h' },
@ -144,6 +146,7 @@ struct option longopts[] = {
{ "gc_to_n64_load_mapping", 1, NULL, OPT_GC_TO_N64_LOAD_MAPPING },
{ "gc_to_n64_store_current_mapping", 1, NULL, OPT_GC_TO_N64_STORE_CURRENT_MAPPING },
{ "nonstop", 0, NULL, OPT_NONSTOP },
{ "get_version", 0, NULL, OPT_GET_VERSION },
{ },
};
@ -487,6 +490,16 @@ int main(int argc, char **argv)
}
}
break;
case OPT_GET_VERSION:
{
char version[64];
if (0 == gcn64lib_getVersion(hdl, version, sizeof(version))) {
printf("Firmware version: %s\n", version);
}
}
break;
}
if (do_exchange) {