ice_tm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/ice-tm +0 -0
- data/ext/baudrate/baudrate.c +12 -7
- data/lib/ice_tm/ice_tm.rb +29 -13
- data/lib/ice_tm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c380f58c33b9453b6a94bd9d75b7680a633896302a21df04c1a3f5fbb924d43
|
4
|
+
data.tar.gz: 6fe6b64fa1a479c37adde8c13b7848e6b961454363e41198e19ac31eb1783e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89ee7e4d43f523b17398f71d1b629136c5032a3a29e6bc06442ab025e42cd732446e46b62b1705dc0e1059aaf97acffbb1580e40623b5168b6dae1fc14e344d
|
7
|
+
data.tar.gz: 2a710389bebb0a1dfc4a90552587f4c5b438489f981e19a232556ceeb523a2e1f15701fd7836ddf7cac26092788af50a4aed3c04b5b608c8fa9ac71d54bb8753
|
data/exe/ice-tm
CHANGED
File without changes
|
data/ext/baudrate/baudrate.c
CHANGED
@@ -12,14 +12,18 @@ VALUE setBaudRate(volatile VALUE obj, volatile VALUE dev, volatile VALUE speed)
|
|
12
12
|
|
13
13
|
char status = tcgetattr(serial_port, &tty) ;
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
/*
|
16
|
+
Serial Monitor sets these flags:
|
17
|
+
|
18
|
+
speed 57600 baud; line = 0;
|
19
|
+
min = 0; time = 0;
|
20
|
+
-brkint -icrnl -imaxbel
|
21
|
+
-opost
|
22
|
+
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
|
23
|
+
*/
|
21
24
|
|
22
25
|
if(status != 0) return Qnil ;
|
26
|
+
|
23
27
|
tty.c_cflag &= ~CSIZE ;
|
24
28
|
tty.c_cflag |= CS8 ;
|
25
29
|
tty.c_cflag |= CREAD | CLOCAL ;
|
@@ -43,7 +47,8 @@ VALUE setBaudRate(volatile VALUE obj, volatile VALUE dev, volatile VALUE speed)
|
|
43
47
|
status = tcsetattr(serial_port, TCSANOW, &tty) ;
|
44
48
|
|
45
49
|
if (status == 0) return Qtrue ;
|
46
|
-
|
50
|
+
|
51
|
+
return Qfalse ;
|
47
52
|
}
|
48
53
|
|
49
54
|
VALUE getBaudRate(volatile VALUE obj, volatile VALUE dev) {
|
data/lib/ice_tm/ice_tm.rb
CHANGED
@@ -23,7 +23,13 @@ module IceTM
|
|
23
23
|
Dir.glob('/dev/ttyUSB[0-9]*').each { |x|
|
24
24
|
if File.writable?(x)
|
25
25
|
puts "#{IceTM::BOLD}#{IceTM::BLUE}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Changing `baudrate` to 57600...#{IceTM::RESET}"
|
26
|
-
|
26
|
+
|
27
|
+
if IceTM.set_baudrate(x, IceTM::BAUDRATE)
|
28
|
+
puts "#{IceTM::BOLD}#{IceTM::BLUE}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Changing baudrate to 57600...#{IceTM::RESET}"
|
29
|
+
else
|
30
|
+
puts "#{IceTM::BOLD}#{IceTM::RED}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Cannot change the baudrate#{IceTM::RESET}"
|
31
|
+
end
|
32
|
+
|
27
33
|
else
|
28
34
|
"#{BOLD}#{RED}:: #{Time.now.strftime('%H:%M:%S.%2N')}: No permission granted to change Baudrate#{RESET}"
|
29
35
|
end
|
@@ -73,14 +79,12 @@ module IceTM
|
|
73
79
|
cpu_u = mem_u = swap_u = iostat = net_upload = net_download = 0
|
74
80
|
|
75
81
|
Thread.new {
|
76
|
-
while true
|
77
|
-
cpu_u = LS::CPU.total_usage(0.125).to_f
|
78
|
-
end
|
82
|
+
cpu_u = LS::CPU.total_usage(0.25).to_f while true
|
79
83
|
}
|
80
84
|
|
81
85
|
Thread.new {
|
82
86
|
while true
|
83
|
-
netstat = LS::Net::current_usage(0.
|
87
|
+
netstat = LS::Net::current_usage(0.25)
|
84
88
|
net_upload = netstat[:transmitted].to_i
|
85
89
|
net_download = netstat[:received].to_i
|
86
90
|
end
|
@@ -101,8 +105,11 @@ module IceTM
|
|
101
105
|
break
|
102
106
|
end
|
103
107
|
rescue EOFError
|
108
|
+
sleep 0.05
|
104
109
|
retry
|
105
110
|
end
|
111
|
+
|
112
|
+
sleep 0.05
|
106
113
|
end
|
107
114
|
|
108
115
|
puts "#{IceTM::BOLD}#{IceTM::GREEN}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Device ready!#{IceTM::RESET}"
|
@@ -130,12 +137,21 @@ module IceTM
|
|
130
137
|
disk_used_percent = convert_percent(diskstat[:used].*(100).fdiv(diskstat[:total]))
|
131
138
|
disk_avail_percent = convert_percent(_diskavail.*(100).fdiv(diskstat[:total]))
|
132
139
|
|
133
|
-
total_process =
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
total_process = ps_r = ps_sl = ps_i = ps_t = ps_z = 0
|
141
|
+
|
142
|
+
# Get process count
|
143
|
+
process_types = LS::Process.types
|
144
|
+
|
145
|
+
total_process = 0
|
146
|
+
process_types.values.each { |x|
|
147
|
+
ps_r += 1 if x == :running
|
148
|
+
ps_sl += 1 if x == :sleeping
|
149
|
+
ps_i += 1 if x == :idle
|
150
|
+
ps_t += 1 if x == :stopped
|
151
|
+
ps_z += 1 if x == :zombie
|
152
|
+
|
153
|
+
total_process += 1
|
154
|
+
}
|
139
155
|
|
140
156
|
# Output has to be exactly this long. If not, ice-taskmanager shows invalid result.
|
141
157
|
# No string is split inside ice-task manager, it just depends on the string length.
|
@@ -172,7 +188,7 @@ module IceTM
|
|
172
188
|
file.syswrite('~')
|
173
189
|
STDOUT.flush
|
174
190
|
|
175
|
-
sleep 0.
|
191
|
+
sleep 0.25
|
176
192
|
end
|
177
193
|
rescue Interrupt, SystemExit, SignalException
|
178
194
|
file &.close
|
@@ -181,7 +197,7 @@ module IceTM
|
|
181
197
|
device = find_device
|
182
198
|
|
183
199
|
unless device
|
184
|
-
puts "#{IceTM::BOLD}#{IceTM::RED}:: #{Time.now.strftime('%H:%M:%S.%2N')}:
|
200
|
+
puts "#{IceTM::BOLD}#{IceTM::RED}:: #{Time.now.strftime('%H:%M:%S.%2N')}: Error establishing connection. Don't worry if this is a valid device. Retrying...#{IceTM::RESET}"
|
185
201
|
sleep 0.1
|
186
202
|
end
|
187
203
|
|
data/lib/ice_tm/version.rb
CHANGED