Skip to content

Commit

Permalink
moc test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoirier committed Dec 16, 2015
1 parent 6169d27 commit 4b89863
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 4 additions & 6 deletions moc_test/gortlsdr/librtlsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void do_init(void) {
.test_mode = 0,
.agc_mode = 0,
.direct_sampling_mode = 1,
.offset_tuning =1000,
.offset_tuning = 1,
.type = RTLSDR_TUNER_R828D,
.eeprom_buffer = {0x28, 0x32, 0x09, 0x01, 0x01, 0x01, 0xA5, 0x03,
0x1F, 0x03, 'R', 0x00, 'E', 0x00, 'A', 0x00, 'L', 0x00, 'T', 0x00, 'E', 0x00, 'K', 0x00,
Expand All @@ -141,7 +141,7 @@ void do_init(void) {
.test_mode = 1,
.agc_mode = 1,
.direct_sampling_mode = 0,
.offset_tuning =1001,
.offset_tuning = 0,
.type = RTLSDR_TUNER_R820T,
.eeprom_buffer = {0x28, 0x32, 0x09, 0x01, 0x01, 0x01, 0xA5, 0x03,
0x1F, 0x03, 'R', 0x00, 'E', 0x00, 'A', 0x00, 'L', 0x00, 'T', 0x00, 'E', 0x00, 'K', 0x00,
Expand All @@ -166,7 +166,7 @@ void do_init(void) {
.test_mode = 0,
.agc_mode = 1,
.direct_sampling_mode = 1,
.offset_tuning =1002,
.offset_tuning = 1,
.type = RTLSDR_TUNER_E4000,
.eeprom_buffer = {0x28, 0x32, 0x09, 0x01, 0x01, 0x01, 0xA5, 0x03,
0x1F, 0x03, 'R', 0x00, 'E', 0x00, 'A', 0x00, 'L', 0x00, 'T', 0x00, 'E', 0x00, 'K', 0x00,
Expand Down Expand Up @@ -424,10 +424,8 @@ int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev){
}

int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on) {
if (!dev)
if (!dev || !dev_valid(dev))
return -1;
if (!dev_valid(dev))
return -2;

dev->offset_tuning = on;
return 0;
Expand Down
16 changes: 8 additions & 8 deletions moc_test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func SetFreqCorrection(d *rtl.Context, i int) {
}

func GetFreqCorrection(d *rtl.Context, i int) {
if ppm := d.GetFreqCorrection(); ppm != -1 {
if ppm := d.GetFreqCorrection(); ppm < 0 {
log.Printf("--- FAILED, GetFreqCorrection i:%d - %d\n", i, ppm)
} else {
log.Printf("--- PASSED, GetFreqCorrection i:%d\n", i)
Expand Down Expand Up @@ -168,7 +168,7 @@ func SetTunerGainMode(d *rtl.Context, i int) {
}

func SetSampleRate(d *rtl.Context, i int) {
rateHz := 3500000
rateHz := 225001
if err := d.SetSampleRate(rateHz); err != nil {
log.Printf("--- FAILED, SetSampleRate i:%d - %s\n", i, err)
} else {
Expand Down Expand Up @@ -272,17 +272,17 @@ func main() {

for i := 0; i < cnt; i++ {
if len(GetDeviceName(i)) == 0 {
log.Printf("--- FAILED, GetDeviceName i:%d\n")
log.Printf("--- FAILED, GetDeviceName i:%d\n", i)
} else {
log.Printf("--- PASSED, GetDeviceName i:%d\n")
log.Printf("--- PASSED, GetDeviceName i:%d\n", i)
}
}

for i := 3; i < 6; i++ {
if len(GetDeviceName(i)) != 0 {
log.Printf("--- FAILED, GetDeviceName i:%d\n")
log.Printf("--- FAILED, GetDeviceName i:%d\n", i)
} else {
log.Printf("--- PASSED, GetDeviceName i:%d\n")
log.Printf("--- PASSED, GetDeviceName i:%d\n", i)
}
}

Expand All @@ -292,15 +292,15 @@ func main() {
log.Printf("--- FAILED, GetDeviceUsbStrings i:%d, %s\n", i, err)
} else {
serials = append(serials, s)
log.Printf("--- PASSED, GetDeviceUsbStrings i:%d\n")
log.Printf("--- PASSED, GetDeviceUsbStrings i:%d\n", i)
}
}

for i := 3; i < 6; i++ {
if _, _, _, err := GetDeviceUsbStrings(i); err == nil {
log.Printf("--- FAILED, GetDeviceUsbStrings i:%d, %s\n", i, err)
} else {
log.Printf("--- PASSED, GetDeviceUsbStrings i:%d\n")
log.Printf("--- PASSED, GetDeviceUsbStrings i:%d\n", i)
}
}

Expand Down

0 comments on commit 4b89863

Please sign in to comment.