/
helpers.go
62 lines (54 loc) · 1.99 KB
/
helpers.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
62
// Copyright 2018 Otis Elevator Company. All rights reserved.
// Use of this source code is govered by the MIT license which
// can be found in the LICENSE file.
// Author: Jeremy Mill: jeremy.mill@otis.com
// Otis udp_rx software has been designed to utilize information
// security technology described in the Category 5 – Part 2 of the
// Commerce Control List, within Part 774 of the Export Administration
// Regulations (“EAR”)(15 CFR 774). However, the Otis udp_rx software
// has been made publicly available in accordance with Part 742.15(b)
// of the EAR and is therefore not subject to U.S. export regulations.
// Before downloading this software, be aware that the country in which
// you are located may have restrictions related to the import, download,
// possession, use and/or reexport of encryption items. It is your
// responsibility to comply with any applicable laws and regulations
// pertaining the import, download, possession, use and/or reexport of
// encryption items.
// Package udprxlib is the driver for udprx
package udprxlib
import (
"os"
"time"
)
var getTime = time.Now().UTC().UnixNano
func intToBytes(input int) []byte {
//this must be less than 1024 so we only have a few use cases
output := make([]byte, 2)
lower := input & 0xFF
output[1] = byte(lower)
upper := (input >> 8) & 0xFF
output[0] = byte(upper)
return output
}
func getTimeBytes() []byte {
barray := make([]byte, 8)
time := getTime()
//fmt.Printf("time is: %d", time)
barray[0] = byte((time >> 56) & 0xFF)
barray[1] = byte((time >> 48) & 0xFF)
barray[2] = byte((time >> 40) & 0xFF)
barray[3] = byte((time >> 32) & 0xFF)
barray[4] = byte((time >> 24) & 0xFF)
barray[5] = byte((time >> 16) & 0xFF)
barray[6] = byte((time >> 8) & 0xFF)
barray[7] = byte(time & 0xFF)
// output := ""
// for _, element := range barray {
// output = output + fmt.Sprintf("%d,", element)
// }
//fmt.Println(output)
return barray
}
func isWindows() bool {
return os.PathSeparator == '\\' && os.PathListSeparator == ';'
}