-
Notifications
You must be signed in to change notification settings - Fork 0
/
TXTest-Obj.spin2
84 lines (63 loc) · 2.79 KB
/
TXTest-Obj.spin2
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
73
74
75
76
77
78
79
80
81
82
83
{
--------------------------------------------
Filename: TXTest-Obj.spin2
Author: Jesse Burt
Description: ZModem transmit from Propeller test (object-oriented ZModem)
Send a file 'p2rom.bin' containing the
Propeller 2's ROM to the remote device
Copyright (c) 2022
Started Jan 2, 2023
Updated Jan 3, 2023
See end of file for terms of use.
--------------------------------------------
}
CON
_clkfreq = 180_000_000
_xtlfreq = 20_000_000
OBJ
com : "com.serial.terminal" ' remote device
ser : "com.serial.terminal.ansi" ' debug/terminal output
zm : "protocol.file-xfer.zmodem"
PUB main() | status[2]
ser.startrxtx(63, 62, 0, 2_000_000)
ser.clear()
com.startrxtx(24, 25, 0, 115_200) ' secondary serial connection
' -- ZModem setup
zm.init(@com.putchar, @com.getchar) ' tell zmodem how to transmit and receive
zm.set_file_sz(16384)
zm.set_file_name(@"p2rom.bin")
zm.set_file_data_ptr($fc000) ' P2 ROM start
' --
ser.printf(@"Filename: %s\n\r", zm.file_name())
ser.printf(@"Size : %u\n\r", zm.file_size())
{ start a new cog to watch the current status of the transfer }
cogspin(NEWCOG, cog_show_status(@status, zm.file_size()), @_status_stk)
zm.send_file(@status) ' initiate the transfer
repeat
VAR
long _status_stk[100]
PUB cog_show_status(ptr_status, file_sz)
repeat until long[ptr_status][1] == 1 ' wait for zmodem to be ready
repeat
ser.pos_xy(0, 5)
ser.printf(@"Transferred %d of %d bytes\n\r", long[ptr_status][0], file_sz)
while (long[ptr_status][1])
ser.strln(@"complete")
cogstop(cogid())
#include "zmodem.common.spinh"
DAT
{
Copyright 2022 Jesse Burt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}