rpi: fix passing unsigned integers to component (#3672)

This commit is contained in:
Alessandro Ros 2024-08-21 00:08:54 +02:00 committed by GitHub
parent 41a3fd503d
commit 3700d5e5b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 21 deletions

View File

@ -72,7 +72,7 @@ func loadEnvInternal(env map[string]string, prefix string, prv reflect.Value) er
}
return nil
case reflect.TypeOf(uint64(0)):
case reflect.TypeOf(uint(0)):
if ev, ok := env[prefix]; ok {
if prv.IsNil() {
prv.Set(reflect.New(rt))

View File

@ -16,7 +16,7 @@ func intPtr(v int) *int {
return &v
}
func uint64Ptr(v uint64) *uint64 {
func uintPtr(v uint) *uint {
return &v
}
@ -75,8 +75,8 @@ type testStruct struct {
MyStringOpt *string `json:"myStringOpt"`
MyInt int `json:"myInt"`
MyIntOpt *int `json:"myIntOpt"`
MyUint uint64 `json:"myUint"`
MyUintOpt *uint64 `json:"myUintOpt"`
MyUint uint `json:"myUint"`
MyUintOpt *uint `json:"myUintOpt"`
MyFloat float64 `json:"myFloat"`
MyFloatOpt *float64 `json:"myFloatOpt"`
MyBool bool `json:"myBool"`
@ -141,7 +141,7 @@ func TestLoad(t *testing.T) {
MyInt: 123,
MyIntOpt: intPtr(456),
MyUint: 8910,
MyUintOpt: uint64Ptr(112313),
MyUintOpt: uintPtr(112313),
MyFloat: 15.2,
MyFloatOpt: float64Ptr(16.2),
MyBool: true,

View File

@ -130,9 +130,9 @@ type Path struct {
SourceRedirect string `json:"sourceRedirect"`
// Raspberry Pi Camera source
RPICameraCamID int `json:"rpiCameraCamID"`
RPICameraWidth int `json:"rpiCameraWidth"`
RPICameraHeight int `json:"rpiCameraHeight"`
RPICameraCamID uint `json:"rpiCameraCamID"`
RPICameraWidth uint `json:"rpiCameraWidth"`
RPICameraHeight uint `json:"rpiCameraHeight"`
RPICameraHFlip bool `json:"rpiCameraHFlip"`
RPICameraVFlip bool `json:"rpiCameraVFlip"`
RPICameraBrightness float64 `json:"rpiCameraBrightness"`
@ -143,7 +143,7 @@ type Path struct {
RPICameraAWB string `json:"rpiCameraAWB"`
RPICameraAWBGains []float64 `json:"rpiCameraAWBGains"`
RPICameraDenoise string `json:"rpiCameraDenoise"`
RPICameraShutter int `json:"rpiCameraShutter"`
RPICameraShutter uint `json:"rpiCameraShutter"`
RPICameraMetering string `json:"rpiCameraMetering"`
RPICameraGain float64 `json:"rpiCameraGain"`
RPICameraEV float64 `json:"rpiCameraEV"`
@ -157,12 +157,12 @@ type Path struct {
RPICameraAfSpeed string `json:"rpiCameraAfSpeed"`
RPICameraLensPosition float64 `json:"rpiCameraLensPosition"`
RPICameraAfWindow string `json:"rpiCameraAfWindow"`
RPICameraFlickerPeriod int `json:"rpiCameraFlickerPeriod"`
RPICameraFlickerPeriod uint `json:"rpiCameraFlickerPeriod"`
RPICameraTextOverlayEnable bool `json:"rpiCameraTextOverlayEnable"`
RPICameraTextOverlay string `json:"rpiCameraTextOverlay"`
RPICameraCodec string `json:"rpiCameraCodec"`
RPICameraIDRPeriod int `json:"rpiCameraIDRPeriod"`
RPICameraBitrate int `json:"rpiCameraBitrate"`
RPICameraIDRPeriod uint `json:"rpiCameraIDRPeriod"`
RPICameraBitrate uint `json:"rpiCameraBitrate"`
RPICameraProfile string `json:"rpiCameraProfile"`
RPICameraLevel string `json:"rpiCameraLevel"`

View File

@ -2,9 +2,9 @@ package rpicamera
type params struct {
LogLevel string
CameraID int
Width int
Height int
CameraID uint
Width uint
Height uint
HFlip bool
VFlip bool
Brightness float64
@ -16,7 +16,7 @@ type params struct {
AWBGainRed float64
AWBGainBlue float64
Denoise string
Shutter int
Shutter uint
Metering string
Gain float64
EV float64
@ -30,12 +30,12 @@ type params struct {
AfSpeed string
LensPosition float64
AfWindow string
FlickerPeriod int
FlickerPeriod uint
TextOverlayEnable bool
TextOverlay string
Codec string
IDRPeriod int
Bitrate int
IDRPeriod uint
Bitrate uint
Profile string
Level string
}

View File

@ -21,8 +21,8 @@ func (p params) serialize() []byte {
f := rv.Field(i)
switch f.Kind() {
case reflect.Int:
entry += strconv.FormatInt(f.Int(), 10)
case reflect.Uint:
entry += strconv.FormatUint(f.Uint(), 10)
case reflect.Float64:
entry += strconv.FormatFloat(f.Float(), 'f', -1, 64)