Skip to content

Commit ac56750

Browse files
Add CI built packages from commit f505858 of update/ruff
1 parent 1443ca3 commit ac56750

File tree

747 files changed

+26661
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

747 files changed

+26661
-0
lines changed

mip/update/ruff/file/01/011649d0

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
#! /usr/bin/env python3
2+
3+
# Copyright 1994 by Lance Ellinghouse
4+
# Cathedral City, California Republic, United States of America.
5+
# All Rights Reserved
6+
# Permission to use, copy, modify, and distribute this software and its
7+
# documentation for any purpose and without fee is hereby granted,
8+
# provided that the above copyright notice appear in all copies and that
9+
# both that copyright notice and this permission notice appear in
10+
# supporting documentation, and that the name of Lance Ellinghouse
11+
# not be used in advertising or publicity pertaining to distribution
12+
# of the software without specific, written prior permission.
13+
# LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
14+
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
15+
# FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE
16+
# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19+
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20+
#
21+
# Modified by Jack Jansen, CWI, July 1995:
22+
# - Use binascii module to do the actual line-by-line conversion
23+
# between ascii and binary. This results in a 1000-fold speedup. The C
24+
# version is still 5 times faster, though.
25+
# - Arguments more compliant with python standard
26+
27+
"""Implementation of the UUencode and UUdecode functions.
28+
29+
encode(in_file, out_file [,name, mode])
30+
decode(in_file [, out_file, mode])
31+
"""
32+
33+
import binascii
34+
import os
35+
import sys
36+
37+
__all__ = ["Error", "encode", "decode"]
38+
39+
40+
class Error(Exception):
41+
pass
42+
43+
44+
def encode(in_file, out_file, name=None, mode=None):
45+
"""Uuencode file"""
46+
#
47+
# If in_file is a pathname open it and change defaults
48+
#
49+
opened_files = []
50+
try:
51+
if in_file == "-":
52+
in_file = sys.stdin.buffer
53+
elif isinstance(in_file, str):
54+
if name is None:
55+
name = os.path.basename(in_file)
56+
if mode is None:
57+
try:
58+
mode = os.stat(in_file).st_mode
59+
except AttributeError:
60+
pass
61+
in_file = open(in_file, "rb")
62+
opened_files.append(in_file)
63+
#
64+
# Open out_file if it is a pathname
65+
#
66+
if out_file == "-":
67+
out_file = sys.stdout.buffer
68+
elif isinstance(out_file, str):
69+
out_file = open(out_file, "wb")
70+
opened_files.append(out_file)
71+
#
72+
# Set defaults for name and mode
73+
#
74+
if name is None:
75+
name = "-"
76+
if mode is None:
77+
mode = 0o666
78+
#
79+
# Write the data
80+
#
81+
out_file.write(("begin %o %s\n" % ((mode & 0o777), name)).encode("ascii"))
82+
data = in_file.read(45)
83+
while len(data) > 0:
84+
out_file.write(binascii.b2a_uu(data))
85+
data = in_file.read(45)
86+
out_file.write(b" \nend\n")
87+
finally:
88+
for f in opened_files:
89+
f.close()
90+
91+
92+
def decode(in_file, out_file=None, mode=None, quiet=False):
93+
"""Decode uuencoded file"""
94+
#
95+
# Open the input file, if needed.
96+
#
97+
opened_files = []
98+
if in_file == "-":
99+
in_file = sys.stdin.buffer
100+
elif isinstance(in_file, str):
101+
in_file = open(in_file, "rb")
102+
opened_files.append(in_file)
103+
104+
try:
105+
#
106+
# Read until a begin is encountered or we've exhausted the file
107+
#
108+
while True:
109+
hdr = in_file.readline()
110+
if not hdr:
111+
raise Error("No valid begin line found in input file")
112+
if not hdr.startswith(b"begin"):
113+
continue
114+
hdrfields = hdr.split(b" ", 2)
115+
if len(hdrfields) == 3 and hdrfields[0] == b"begin":
116+
try:
117+
int(hdrfields[1], 8)
118+
break
119+
except ValueError:
120+
pass
121+
if out_file is None:
122+
# If the filename isn't ASCII, what's up with that?!?
123+
out_file = hdrfields[2].rstrip(b" \t\r\n\f").decode("ascii")
124+
if os.path.exists(out_file):
125+
raise Error("Cannot overwrite existing file: %s" % out_file)
126+
if mode is None:
127+
mode = int(hdrfields[1], 8)
128+
#
129+
# Open the output file
130+
#
131+
if out_file == "-":
132+
out_file = sys.stdout.buffer
133+
elif isinstance(out_file, str):
134+
fp = open(out_file, "wb")
135+
try:
136+
os.path.chmod(out_file, mode)
137+
except AttributeError:
138+
pass
139+
out_file = fp
140+
opened_files.append(out_file)
141+
#
142+
# Main decoding loop
143+
#
144+
s = in_file.readline()
145+
while s and s.strip(b" \t\r\n\f") != b"end":
146+
try:
147+
data = binascii.a2b_uu(s)
148+
except binascii.Error as v:
149+
# Workaround for broken uuencoders by /Fredrik Lundh
150+
nbytes = (((s[0] - 32) & 63) * 4 + 5) // 3
151+
data = binascii.a2b_uu(s[:nbytes])
152+
if not quiet:
153+
sys.stderr.write("Warning: %s\n" % v)
154+
out_file.write(data)
155+
s = in_file.readline()
156+
if not s:
157+
raise Error("Truncated input file")
158+
finally:
159+
for f in opened_files:
160+
f.close()
161+
162+
163+
def test():
164+
"""uuencode/uudecode main program"""
165+
166+
import optparse
167+
168+
parser = optparse.OptionParser(usage="usage: %prog [-d] [-t] [input [output]]")
169+
parser.add_option(
170+
"-d",
171+
"--decode",
172+
dest="decode",
173+
help="Decode (instead of encode)?",
174+
default=False,
175+
action="store_true",
176+
)
177+
parser.add_option(
178+
"-t",
179+
"--text",
180+
dest="text",
181+
help="data is text, encoded format unix-compatible text?",
182+
default=False,
183+
action="store_true",
184+
)
185+
186+
(options, args) = parser.parse_args()
187+
if len(args) > 2:
188+
parser.error("incorrect number of arguments")
189+
sys.exit(1)
190+
191+
# Use the binary streams underlying stdin/stdout
192+
input = sys.stdin.buffer
193+
output = sys.stdout.buffer
194+
if len(args) > 0:
195+
input = args[0]
196+
if len(args) > 1:
197+
output = args[1]
198+
199+
if options.decode:
200+
if options.text:
201+
if isinstance(output, str):
202+
output = open(output, "wb")
203+
else:
204+
print(sys.argv[0], ": cannot do -t to stdout")
205+
sys.exit(1)
206+
decode(input, output)
207+
else:
208+
if options.text:
209+
if isinstance(input, str):
210+
input = open(input, "rb")
211+
else:
212+
print(sys.argv[0], ": cannot do -t from stdin")
213+
sys.exit(1)
214+
encode(input, output)
215+
216+
217+
if __name__ == "__main__":
218+
test()
219+
220+
221+
__version__ = '0.5.1'

mip/update/ruff/file/01/018bf3cb

1.57 KB
Binary file not shown.

mip/update/ruff/file/01/01e5d0ca

362 Bytes
Binary file not shown.

mip/update/ruff/file/02/0241dbfe

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# MicroPython LoRa STM32WL55 embedded sub-ghz radio driver
2+
# MIT license; Copyright (c) 2022 Angus Gratton
3+
#
4+
# This driver is essentially an embedded SX1262 with a custom internal interface block.
5+
# Requires the stm module in MicroPython to be compiled with STM32WL5 subghz radio support.
6+
#
7+
# LoRa is a registered trademark or service mark of Semtech Corporation or its affiliates.
8+
from machine import Pin, SPI
9+
import stm
10+
from . import sx126x
11+
from micropython import const
12+
13+
_CMD_CLR_ERRORS = const(0x07)
14+
15+
_REG_OCP = const(0x8E7)
16+
17+
# Default antenna switch config is as per Nucleo WL-55 board. See UM2592 Fig 18.
18+
# Possible to work with other antenna switch board configurations by passing
19+
# different ant_sw_class arguments to the modem, any class that creates an object with rx/tx
20+
21+
22+
class NucleoWL55RFConfig:
23+
def __init__(self):
24+
self._FE_CTRL = (Pin(x, mode=Pin.OUT) for x in ("C4", "C5", "C3"))
25+
26+
def _set_fe_ctrl(self, values):
27+
for pin, val in zip(self._FE_CTRL, values):
28+
pin(val)
29+
30+
def rx(self):
31+
self._set_fe_ctrl((1, 0, 1))
32+
33+
def tx(self, hp):
34+
self._set_fe_ctrl((0 if hp else 1, 1, 1))
35+
36+
def idle(self):
37+
pass
38+
39+
40+
class DIO1:
41+
# Dummy DIO1 "Pin" wrapper class to pass to the _SX126x class
42+
def irq(self, handler, _):
43+
stm.subghz_irq(handler)
44+
45+
46+
class _WL55SubGhzModem(sx126x._SX126x):
47+
# Don't construct this directly, construct lora.WL55SubGhzModem or lora.AsyncWL55SubGHzModem
48+
def __init__(
49+
self,
50+
lora_cfg=None,
51+
tcxo_millivolts=1700,
52+
ant_sw=NucleoWL55RFConfig,
53+
):
54+
self._hp = False
55+
56+
if ant_sw == NucleoWL55RFConfig:
57+
# To avoid the default argument being an object instance
58+
ant_sw = NucleoWL55RFConfig()
59+
60+
super().__init__(
61+
# RM0453 7.2.13 says max 16MHz, but this seems more stable
62+
SPI("SUBGHZ", baudrate=8_000_000),
63+
stm.subghz_cs,
64+
stm.subghz_is_busy,
65+
DIO1(),
66+
False, # dio2_rf_sw
67+
tcxo_millivolts, # dio3_tcxo_millivolts
68+
10_000, # dio3_tcxo_start_time_us, first time after POR is quite long
69+
None, # reset
70+
lora_cfg,
71+
ant_sw,
72+
)
73+
74+
def _clear_errors(self):
75+
# A weird difference between STM32WL55 and SX1262, WL55 only takes one
76+
# parameter byte for the Clr_Error() command compared to two on SX1262.
77+
# The bytes are always zero in both cases.
78+
#
79+
# (Not clear if sending two bytes will also work always/sometimes, but
80+
# sending one byte to SX1262 definitely does not work!
81+
self._cmd("BB", _CMD_CLR_ERRORS, 0x00)
82+
83+
def _clear_irq(self, clear_bits=0xFFFF):
84+
super()._clear_irq(clear_bits)
85+
# SUBGHZ Radio IRQ requires manual re-enabling after interrupt
86+
stm.subghz_irq(self._radio_isr)
87+
88+
def _tx_hp(self):
89+
# STM32WL5 supports both High and Low Power antenna pins depending on tx_ant setting
90+
return self._hp
91+
92+
def _get_pa_tx_params(self, output_power, tx_ant):
93+
# Given an output power level in dBm and the tx_ant setting (if any),
94+
# return settings for SetPaConfig and SetTxParams.
95+
#
96+
# ST document RM0453 Set_PaConfig() reference and accompanying Table 35
97+
# show values that are an exact superset of the SX1261 and SX1262
98+
# available values, depending on which antenna pin is to be
99+
# used. Therefore, call either modem's existing _get_pa_tx_params()
100+
# function depending on the current tx_ant setting (default is low
101+
# power).
102+
103+
if tx_ant is not None:
104+
# Note: currently HP antenna power output is less than it should be,
105+
# due to some (unknown) bug.
106+
self._hp = tx_ant == "PA_BOOST"
107+
108+
# Update the OCP register to match the maximum power level
109+
self._reg_write(_REG_OCP, 0x38 if self._hp else 0x18)
110+
111+
if self._hp:
112+
return sx126x._SX1262._get_pa_tx_params(self, output_power, tx_ant)
113+
else:
114+
return sx126x._SX1261._get_pa_tx_params(self, output_power, tx_ant)
115+
116+
117+
# Define the actual modem classes that use the SyncModem & AsyncModem "mixin-like" classes
118+
# to create sync and async variants.
119+
120+
try:
121+
from .sync_modem import SyncModem
122+
123+
class WL55SubGhzModem(_WL55SubGhzModem, SyncModem):
124+
pass
125+
126+
except ImportError:
127+
pass
128+
129+
try:
130+
from .async_modem import AsyncModem
131+
132+
class AsyncWL55SubGhzModem(_WL55SubGhzModem, AsyncModem):
133+
pass
134+
135+
except ImportError:
136+
pass
137+
138+
139+
__version__ = '0.1'

mip/update/ruff/file/02/02f60473

649 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)