-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslpacket.go
61 lines (50 loc) · 1.7 KB
/
slpacket.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package slink
//#cgo CFLAGS: -I/usr/local/include
//#cgo LDFLAGS: /usr/local/lib/libslink.a
//#include <libslink.h>
import "C"
import (
//"bytes"
"unsafe"
)
const (
SLRECSIZE int = 512
SLHEADSIZE int = 8
)
const (
SLPACKET int = 1
SLTERMINATE int = 0
SLNOPACKET int = -1
)
type Type int
const (
SLDATA Type = iota // waveform data record
SLDET // detection record
SLCAL // calibration record
SLTIM // timing record
SLMSG // message record
SLBLK // general record
SLNUM // used as the error indicator (same as SLCHA)
SLCHA // for requesting channel info or detectors
SLINF // a non-terminating XML formatted message in a miniSEED log record, used for INFO responses
SLINFT // a terminating XML formatted message in a miniSEED log record, used for INFO responses
SLKEEP // an XML formatted message in a miniSEED log record, used for keepalive/heartbeat responses
)
type SLPacket _Ctype_SLpacket
func (p *SLPacket) Sequence() int {
return (int)(C.sl_sequence((*C.struct_slpacket_s)(p)))
}
func (p *SLPacket) PacketType() Type {
return (Type)(C.sl_packettype((*C.struct_slpacket_s)(p)))
}
func (p *SLPacket) GetMSRecord() []byte {
return C.GoBytes(unsafe.Pointer(&p.msrecord[0]), (C.int)(SLRECSIZE))
}
func (p *SLPacket) GetSLHead() []byte {
return C.GoBytes(unsafe.Pointer(&p.slhead[0]), (C.int)(SLHEADSIZE))
}
func (p *SLPacket) ParseRecord(blktflag, unpackflag int8) *SLMSRecord {
msr := C.sl_msr_new()
C.sl_msr_parse((*C.struct_SLlog_s)(nil), (*_Ctype_char)(unsafe.Pointer(&p.msrecord[0])), &msr, (C.int8_t)(blktflag), (C.int8_t)(unpackflag))
return (*SLMSRecord)(msr)
}