Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chain33-pai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
szh
chain33-pai
Commits
16b50ca6
Commit
16b50ca6
authored
Jul 22, 2020
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加linux x86_64架构的兼容
parent
7884dc8b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
11 deletions
+88
-11
main.go
main.go
+16
-1
cmd.go
pkg/app/cmd.go
+38
-0
sys.go
pkg/app/sys.go
+14
-0
pai.go
service/pai_service/pai.go
+20
-10
No files found.
main.go
View file @
16b50ca6
//+build go1.9
package
main
import
(
...
...
@@ -12,6 +14,7 @@ import (
log
"github.com/33cn/chain33/common/log/log15"
"net/http"
"time"
"flag"
)
func
init
()
{
...
...
@@ -25,7 +28,10 @@ func init() {
}
var
tlog
=
log
.
New
(
"main"
,
"main.go"
)
var
(
versionCmd
=
flag
.
Bool
(
"v"
,
false
,
"version"
)
testCmd
=
flag
.
Bool
(
"t"
,
false
,
"test"
)
)
// @title Golang Gin API
// @version 1.0
// @description An example of gin
...
...
@@ -33,6 +39,15 @@ var tlog = log.New("main", "main.go")
// @license.name MIT
// @license.url https://chain33-pai/blob/master/LICENSE
func
main
()
{
flag
.
Parse
()
if
*
versionCmd
{
fmt
.
Println
(
app
.
GetVersion
())
return
}
if
*
testCmd
{
fmt
.
Println
(
"app sys:"
,
app
.
GetLocalArchType
(),
app
.
GetArchType
())
return
}
gin
.
SetMode
(
setting
.
ServerSetting
.
RunMode
)
//区域网广播设备
go
app
.
Broadcast
()
...
...
pkg/app/cmd.go
0 → 100644
View file @
16b50ca6
package
app
import
(
"os/exec"
"bytes"
"strings"
)
func
GetLocalArchType
()
string
{
cmd
:=
exec
.
Command
(
"arch"
)
var
buf
bytes
.
Buffer
cmd
.
Stdout
=
&
buf
cmd
.
Run
()
if
buf
.
String
()
!=
""
{
lines
:=
strings
.
Split
(
buf
.
String
(),
"
\n
"
)
if
len
(
lines
)
==
2
{
return
strings
.
Trim
(
lines
[
0
],
" "
)
}
return
""
}
return
""
}
func
GetLocalUuid
()
string
{
cmd
:=
exec
.
Command
(
"bash"
,
"-c"
,
"dmidecode | grep UUID"
)
var
buf
bytes
.
Buffer
cmd
.
Stdout
=
&
buf
cmd
.
Run
()
if
buf
.
String
()
!=
""
{
lines
:=
strings
.
Split
(
buf
.
String
(),
"
\n
"
)
if
len
(
lines
)
==
2
{
return
strings
.
Trim
(
lines
[
0
],
" "
)
}
return
""
}
return
""
}
\ No newline at end of file
pkg/app/sys.go
0 → 100644
View file @
16b50ca6
package
app
//默认arm架构的树莓派 其他x86_64系统
var
(
ArchType
string
)
func
GetArchType
()
string
{
if
ArchType
!=
""
{
return
ArchType
}
return
"arm"
}
\ No newline at end of file
service/pai_service/pai.go
View file @
16b50ca6
...
...
@@ -17,6 +17,7 @@ import (
"os/exec"
"strconv"
"strings"
"chain33-pai/pkg/app"
)
var
(
...
...
@@ -91,17 +92,26 @@ func (p *Pai) GetConfig() bool {
if
p
.
Serial
!=
""
{
return
true
}
config
,
err
:=
getPaiConfig
(
"cat"
,
"/proc/cpuinfo"
)
if
err
!=
nil
{
p
.
Err
=
err
.
Error
()
return
false
}
if
_
,
ok
:=
config
[
"serial"
];
ok
{
p
.
Serial
=
config
[
"serial"
]
p
.
Hardware
=
config
[
"hardware"
]
p
.
Revision
=
config
[
"revision"
]
return
true
if
app
.
GetArchType
()
==
"arm"
{
config
,
err
:=
getPaiConfig
(
"cat"
,
"/proc/cpuinfo"
)
if
err
!=
nil
{
p
.
Err
=
err
.
Error
()
return
false
}
if
_
,
ok
:=
config
[
"serial"
];
ok
{
p
.
Serial
=
config
[
"serial"
]
p
.
Hardware
=
config
[
"hardware"
]
p
.
Revision
=
config
[
"revision"
]
return
true
}
}
else
if
app
.
GetArchType
()
==
"x86_64"
{
uuid
:=
app
.
GetLocalUuid
()
if
uuid
!=
""
{
p
.
Serial
=
uuid
return
true
}
}
return
false
}
...
...
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