This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* esp32: Added New scripts and updates for Sequans LTE modem firmware Upgrading * New Stable Version v1.18.1 - Added Updated Scripts for Sequans LTE modem as frozen code. - Added support for upgrading Sequans modem over Uart. * py/mkrules.mk: fixed error
- Loading branch information
Islam Wahdan
authored
Aug 28, 2018
1 parent
46a2425
commit f517b1d
Showing
23 changed files
with
1,433 additions
and
8 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# -*- python -*- | ||
################################################################# | ||
# | ||
# Module : CODEC | ||
# Purpose: Base encoders/decoders | ||
# | ||
################################################################# | ||
# | ||
# Copyright (c) 2011 SEQUANS Communications. | ||
# All rights reserved. | ||
# | ||
# This is confidential and proprietary source code of SEQUANS | ||
# Communications. The use of the present source code and all | ||
# its derived forms is exclusively governed by the restricted | ||
# terms and conditions set forth in the SEQUANS | ||
# Communications' EARLY ADOPTER AGREEMENT and/or LICENCE | ||
# AGREEMENT. The present source code and all its derived | ||
# forms can ONLY and EXCLUSIVELY be used with SEQUANS | ||
# Communications' products. The distribution/sale of the | ||
# present source code and all its derived forms is EXCLUSIVELY | ||
# RESERVED to regular LICENCE holder and otherwise STRICTLY | ||
# PROHIBITED. | ||
# | ||
################################################################# | ||
import struct, array | ||
|
||
LITTLE_ENDIAN = "<" | ||
NATIVE_ENDIAN = "=" | ||
BIG_ENDIAN = ">" | ||
|
||
# -------------------------------------------------// Utility /__________________________________ | ||
class encode: | ||
@staticmethod | ||
def u32 (value, endian = BIG_ENDIAN): | ||
return array.array("c", struct.pack(endian + "I", value)) | ||
|
||
@staticmethod | ||
def s32 (value, endian = BIG_ENDIAN): | ||
if value < 0: | ||
value = 0x100000000 + value | ||
return encode.u32(value, endian) | ||
|
||
@staticmethod | ||
def u16 (value, endian = BIG_ENDIAN): | ||
return array.array("c", struct.pack(endian + "H", value)) | ||
|
||
@staticmethod | ||
def u8 (value, endian = None): | ||
return array.array("c", chr(value)) | ||
|
||
@staticmethod | ||
def string (value, endian = None): | ||
return array.array("c", value + "\x00") | ||
|
||
class decode: | ||
@staticmethod | ||
def u32 (value, endian = BIG_ENDIAN): | ||
return struct.unpack(endian + "I", value)[0] | ||
|
||
@staticmethod | ||
def s32 (value, endian = BIG_ENDIAN): | ||
v = decode.u32(value, endian) | ||
if v & (1 << 31): | ||
return v - 0x100000000 | ||
return v | ||
|
||
@staticmethod | ||
def u16 (value, endian = BIG_ENDIAN): | ||
return struct.unpack(endian + "H", value)[0] | ||
|
||
@staticmethod | ||
def u8 (value, endian = None): | ||
return ord(value) | ||
|
||
@staticmethod | ||
def string (value, endian = None): | ||
offset = 0 | ||
str = "" | ||
c = value[offset] | ||
while c != '\x00': | ||
offset += 1 | ||
str += c | ||
c = value[offset] | ||
|
||
return str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- python -*- | ||
################################################################# | ||
# | ||
# Module : CRC | ||
# Purpose: CRC calculation | ||
# | ||
################################################################# | ||
# | ||
# Copyright (c) 2011 SEQUANS Communications. | ||
# All rights reserved. | ||
# | ||
# This is confidential and proprietary source code of SEQUANS | ||
# Communications. The use of the present source code and all | ||
# its derived forms is exclusively governed by the restricted | ||
# terms and conditions set forth in the SEQUANS | ||
# Communications' EARLY ADOPTER AGREEMENT and/or LICENCE | ||
# AGREEMENT. The present source code and all its derived | ||
# forms can ONLY and EXCLUSIVELY be used with SEQUANS | ||
# Communications' products. The distribution/sale of the | ||
# present source code and all its derived forms is EXCLUSIVELY | ||
# RESERVED to regular LICENCE holder and otherwise STRICTLY | ||
# PROHIBITED. | ||
# | ||
################################################################# | ||
import sqnscodec as codec | ||
|
||
# -------------------------------------------------// Fletcher /_________________________________ | ||
def fletcher32 (data): | ||
l = len(data) | ||
|
||
index = 0 | ||
s1 = s2 = 0xFFFF | ||
while l > 1: | ||
qty = 720 if l > 720 else (l & ~1) | ||
l -= qty | ||
|
||
qty += index | ||
while index < qty: | ||
word = codec.decode.u16(data[index:index+2]) | ||
s1 += word | ||
s2 += s1 | ||
|
||
index += 2 | ||
|
||
s1 = (s1 & 0xFFFF) + (s1 >> 16) | ||
s2 = (s2 & 0xFFFF) + (s2 >> 16) | ||
|
||
if (l & 1): | ||
s1 += ord(data[index]) << 8 | ||
s2 += s1 | ||
|
||
s1 = (s1 & 0xFFFF) + (s1 >> 16) | ||
s2 = (s2 & 0xFFFF) + (s2 >> 16) | ||
|
||
s1 = (s1 & 0xFFFF) + (s1 >> 16) | ||
s2 = (s2 & 0xFFFF) + (s2 >> 16) | ||
|
||
return (s2 << 16) | s1 |
Oops, something went wrong.