-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole_IO.py
72 lines (64 loc) · 1.59 KB
/
console_IO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import crc16
def choose_checksum():
i = -1
while i not in [1, 2]:
print("1. - CheckSum as sum of all characters in block mod 256 \n"
"2. - CheckSum as CRC")
try:
i = int(input())
except ValueError:
print("choose 1 or 2")
pass
if i == 1:
return "algebraic"
elif i == 2:
return "CRC"
raise ValueError
def choose_COM():
i = -1
while i not in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
print("Choose port: \n"
"1 - COM1\n"
"2 - COM2\n"
"3 - COM3\n"
"4 - COM4\n"
"5 - COM5\n"
"6 - COM6\n"
"7 - COM7\n"
"8 - COM8\n"
"9 - COM9\n")
try:
i = int(input())
except ValueError:
print("choose an INT between 1 and 9")
pass
strReturn = "COM" + str(i)
return strReturn
def suma_kontrolna_algebraiczna(block):
global checksumType
if checksumType == "algebraic":
suma = 0
for i in block:
suma += i
suma = suma % 256
return suma
elif checksumType == "CRC":
print(type(block[0]))
crc = crc16.crc16xmodem(block)
return crc
pass
return 0
def choose_file():
i = ""
while True:
print("type file name with extension")
try:
i = str(input())
except ValueError:
continue
break
return i
if __name__ == "__main__":
liczba = int(input())
for i in range(0, max(0, liczba)):
print(i)