commit | 6afb56af8a4c6c931476eef46e70c69c6fee3fff | [log] [tgz] |
---|---|---|
author | Girish Gowdra <girish@opennetworking.org> | Tue Apr 27 17:47:57 2021 -0700 |
committer | Girish Gowdra <girish@opennetworking.org> | Fri May 07 17:10:38 2021 +0000 |
tree | 6b01d497952582e9aef9dc95f4ea21d5cc92db4f | |
parent | 366ef1962b18242299605eb4a01ee746150c4060 [diff] [blame] |
VOL-4028: Support ANI-G test message at openonu-go adapter Change-Id: Ibcdcf67e3f80fc30d673c1d8cc657bff654e9ee6
diff --git a/internal/pkg/onuadaptercore/openonu_utils.go b/internal/pkg/onuadaptercore/openonu_utils.go index 32eeed8..2d17b05 100644 --- a/internal/pkg/onuadaptercore/openonu_utils.go +++ b/internal/pkg/onuadaptercore/openonu_utils.go
@@ -71,3 +71,13 @@ } return out } + +// TwosComplementToSignedInt16 convert 2s complement to signed int16 +func TwosComplementToSignedInt16(val uint16) int16 { + var uint16MsbMask uint16 = 0x8000 + if val&uint16MsbMask == uint16MsbMask { + return int16(^val+1) * -1 + } + + return int16(val) +}