forked from bemasher/rtltcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtltcp_test.go
More file actions
38 lines (29 loc) · 727 Bytes
/
rtltcp_test.go
File metadata and controls
38 lines (29 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package rtltcp
import (
"fmt"
"io"
"log"
"net"
)
func Example_sDR() {
var sdr SDR
// Resolve address, this may be ip:port or hostname:port.
addr, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:1234")
if err != nil {
log.Fatal("Error resolving address:", err)
}
// Connect to address and defer close.
sdr.Connect(addr)
defer sdr.Close()
// Print dongle info.
fmt.Printf("%+v\n", sdr.Info)
// Example: {Magic:"RTL0" Tuner:R820T GainCount:29}
// Create an array of bytes for samples.
buf := make([]byte, 16384)
// Read the entire array. This is usually done in a loop.
_, err = io.ReadFull(sdr, buf)
if err != nil {
log.Fatal("Error reading samples:", err)
}
// Do something with data in buf...
}