Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
2401-0022-lte-fire-alarm
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
이병복
2401-0022-lte-fire-alarm
Commits
ccc6bf40
Commit
ccc6bf40
authored
Jul 12, 2024
by
이병복
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
테스트 프로그램수정
parent
49b573dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
48 deletions
+17
-48
main.go
cmd/app-test-server/main.go
+17
-48
No files found.
cmd/app-test-server/main.go
View file @
ccc6bf40
package
main
import
(
"encoding/binary"
"fmt"
"net"
"time"
"golang.org/x/text/encoding/korean"
)
var
testData
=
[][]
byte
{
{
64
,
1
,
24
,
7
,
11
,
13
,
49
,
17
,
0
,
0
,
1
,
1
,
0
,
0
,
1
,
2
,
50
,
195
,
254
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
191
,
161
,
186
,
241
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
64
,
0
,
24
,
7
,
11
,
13
,
49
,
18
,
0
,
0
,
1
,
1
,
0
,
0
,
1
,
2
,
50
,
195
,
254
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
191
,
161
,
186
,
241
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
64
,
1
,
24
,
7
,
11
,
13
,
49
,
19
,
0
,
0
,
1
,
1
,
0
,
0
,
1
,
2
,
50
,
195
,
254
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
191
,
161
,
186
,
241
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
64
,
0
,
24
,
7
,
11
,
13
,
49
,
20
,
0
,
0
,
1
,
1
,
0
,
0
,
1
,
2
,
50
,
195
,
254
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
191
,
161
,
186
,
241
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
}
func
main
()
{
listener
,
err
:=
net
.
Listen
(
"tcp"
,
":12345"
)
if
err
!=
nil
{
...
...
@@ -31,52 +35,17 @@ func main() {
func
handleConnection
(
conn
net
.
Conn
)
{
defer
conn
.
Close
()
for
{
// 테스트 데이터 생성
testData
:=
createTestData
()
fmt
.
Println
(
"New client connected"
)
_
,
err
:=
conn
.
Write
(
testData
)
if
err
!=
nil
{
fmt
.
Println
(
"Error sending data:"
,
err
)
return
for
{
for
_
,
data
:=
range
testData
{
_
,
err
:=
conn
.
Write
(
data
)
if
err
!=
nil
{
fmt
.
Println
(
"Error sending data:"
,
err
)
return
}
fmt
.
Printf
(
"Sent data: %v
\n
"
,
data
)
time
.
Sleep
(
5
*
time
.
Second
)
// 5초 간격으로 데이터 전송
}
time
.
Sleep
(
10
*
time
.
Second
)
// 10초마다 데이터 전송
}
}
func
createTestData
()
[]
byte
{
data
:=
make
([]
byte
,
64
)
// Log_size
data
[
0
]
=
64
// Log_type
data
[
1
]
=
1
// Log_datetime (2024-07-01 15:30:00)
binary
.
LittleEndian
.
PutUint16
(
data
[
2
:
4
],
2024
)
data
[
4
]
=
7
// month
data
[
5
]
=
1
// day
data
[
6
]
=
15
// hour
data
[
7
]
=
30
// minute
data
[
8
]
=
0
// second
// Log_On
data
[
9
]
=
1
// Log_Address
copy
(
data
[
10
:
17
],
[]
byte
(
"A1B2C3D"
))
// Log_Area (EUC-KR 인코딩)
area
:=
"소방서 1"
areaEncoded
,
_
:=
korean
.
EUCKR
.
NewEncoder
()
.
Bytes
([]
byte
(
area
))
copy
(
data
[
17
:
41
],
areaEncoded
)
// Log_Device (EUC-KR 인코딩)
device
:=
"연기감지기"
deviceEncoded
,
_
:=
korean
.
EUCKR
.
NewEncoder
()
.
Bytes
([]
byte
(
device
))
copy
(
data
[
41
:
],
deviceEncoded
)
return
data
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment