mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-03-09 16:59:08 +01:00
Serial number firmware and host-side changes. Very hacky at this point.
Among the TODOs: * Refactor obtaining LPC serial number and chip ID into separate API and header/source files. Remove from main(). * Create a usb_set_serial_number_descriptor() or similar function to be called before USB stack is started. * Ensure USB serial number descriptor is valid even if code forgets to initialize the serial number before the USB stack is started. May be as simple as providing default initializer for usb_descriptor_string_serial_number[]. * Create a #define/constant for the usb_descriptor_string_serial_number length. * Identify what's causing intermittent crashes in hackrf_transfer when no serial number is specified. I'm probably misusing getopt. * Permit serial number without leading zeros so you don't have to type as much. * Add support for serial number argument in other hackrf_* tools. * Provide libhackrf support for enumerating multiple HackRFs, so that hackrf_info can list all devices. May require an additional libhackrf function, outside of hackrf_open(). ...and anything else that makes this less of a hack.
This commit is contained in:
committed by
Heikki Hannikainen
parent
50a6622ff8
commit
9dbe967bf2
@@ -422,6 +422,7 @@ int tx_callback(hackrf_transfer* transfer) {
|
||||
|
||||
static void usage() {
|
||||
printf("Usage:\n");
|
||||
printf("\t[-d serial_number] # Serial number of desired HackRF.\n");
|
||||
printf("\t-r <filename> # Receive data into file.\n");
|
||||
printf("\t-t <filename> # Transmit data from file.\n");
|
||||
printf("\t-w # Receive data into file with WAV header and automatic name.\n");
|
||||
@@ -477,6 +478,7 @@ int main(int argc, char** argv) {
|
||||
char path_file[PATH_FILE_MAX_LEN];
|
||||
char date_time[DATE_TIME_MAX_LEN];
|
||||
const char* path = NULL;
|
||||
const char* serial_number = NULL;
|
||||
int result;
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
@@ -486,7 +488,7 @@ int main(int argc, char** argv) {
|
||||
float time_diff;
|
||||
unsigned int lna_gain=8, vga_gain=20, txvga_gain=0;
|
||||
|
||||
while( (opt = getopt(argc, argv, "wr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:")) != EOF )
|
||||
while( (opt = getopt(argc, argv, "wr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:d:")) != EOF )
|
||||
{
|
||||
result = HACKRF_SUCCESS;
|
||||
switch( opt )
|
||||
@@ -505,6 +507,10 @@ int main(int argc, char** argv) {
|
||||
path = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
automatic_tuning = true;
|
||||
result = parse_u64(optarg, &freq_hz);
|
||||
@@ -776,7 +782,7 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
result = hackrf_open(serial_number, &device);
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
usage();
|
||||
|
||||
Reference in New Issue
Block a user