Skip to content
This repository was archived by the owner on Apr 25, 2021. It is now read-only.

Commit cf59f93

Browse files
committedOct 18, 2018
Release OpenPython firmware v1.0.0
- Python Interpreter
1 parent 2fb37b0 commit cf59f93

File tree

6 files changed

+13178
-1
lines changed

6 files changed

+13178
-1
lines changed
 

‎src/main/java/kr/pe/ecmaxp/openpython/arch/OpenPythonArchitecture.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open class OpenPythonArchitecture(val machine: Machine) : Architecture {
2323
close()
2424

2525
try {
26-
val firmware = OpenPythonFirmware("debug") // TODO: OpenPythonFirmware mapping
26+
val firmware = OpenPythonFirmware("v1.0.0") // TODO: OpenPythonFirmware mapping
2727
recomputeMemory(machine.host().internalComponents())
2828
vm = OpenPythonVirtualMachine(machine, totalMemory, firmware)
2929
} catch (e: Exception) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--[==[
2+
"""OpenPython EEPROM"""
3+
4+
5+
def main():
6+
globals().pop('main')
7+
from ucomponent import invoke, get_list as get_components
8+
from ucomputer import crash, get_computer_address
9+
10+
def component(t):
11+
seq = get_components(t)
12+
return seq[0] if seq else None
13+
14+
def check_bootable(filesystems, address):
15+
return address in filesystems and invoke(address, 'exists', '/init.py')
16+
17+
eeprom = __path__
18+
filesystems = get_components("filesystem")
19+
20+
address = invoke(eeprom, 'getData').decode()
21+
if not check_bootable(filesystems, address):
22+
invoke(__path__, 'setData', b'')
23+
for address in filesystems:
24+
if check_bootable(filesystems, address):
25+
invoke(eeprom, 'setData', address.encode())
26+
break
27+
else:
28+
crash("no bootable medium found")
29+
30+
computer = get_computer_address()
31+
invoke(computer, 'beep', 1000, 0.2)
32+
33+
gpu = component("gpu")
34+
monitor = component("monitor")
35+
if gpu and monitor:
36+
invoke(gpu, "bind", monitor)
37+
38+
def load(address):
39+
handle = invoke(address, 'open', '/init.py', 'r')
40+
buffer = []
41+
42+
try:
43+
while True:
44+
buf = invoke(address, 'read', handle, 4096)
45+
if not buf: break
46+
buffer.append(buf)
47+
finally:
48+
invoke(address, 'close', handle)
49+
handle.dispose()
50+
51+
content = b"".join(buffer)
52+
return content.decode()
53+
54+
content = load(address)
55+
context = {'__name__': '__main__', '__path__': address}
56+
func = compile(content, '/init.py', "exec")
57+
exec(func, context)
58+
59+
60+
if __name__ == '__main__':
61+
main()
62+
63+
# ]==] error "This EEPROM requires a CPU running the OpenPython architecture."
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)
Failed to load comments.