ice_tm 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b75ddb028fb7f91ece76d947e7baaf49ca49834e94fd8eb511dc8bc358d320f
4
- data.tar.gz: 102c2e59d34635e2dcdd5518e5acda17cc33c16e26eec46dff5d7e09c924c411
3
+ metadata.gz: 6c380f58c33b9453b6a94bd9d75b7680a633896302a21df04c1a3f5fbb924d43
4
+ data.tar.gz: 6fe6b64fa1a479c37adde8c13b7848e6b961454363e41198e19ac31eb1783e2d
5
5
  SHA512:
6
- metadata.gz: 7ebe5c6589697b31a5bf8b7d158bc99220eb043807720223556e4236544f8d5ce52cdcd61756a619dab0f3daa9f921c8ff0cf4c984b3cc416d21edf3d6d610f7
7
- data.tar.gz: 41e1f87dd7ed6259ef5fd58768bbfad923c42060d036c3f35f2bd1bc651ca906d3cf7a4c383b3f701883e3799fb5cf02c78ddca6de3698cb85134392c89221f3
6
+ metadata.gz: f89ee7e4d43f523b17398f71d1b629136c5032a3a29e6bc06442ab025e42cd732446e46b62b1705dc0e1059aaf97acffbb1580e40623b5168b6dae1fc14e344d
7
+ data.tar.gz: 2a710389bebb0a1dfc4a90552587f4c5b438489f981e19a232556ceeb523a2e1f15701fd7836ddf7cac26092788af50a4aed3c04b5b608c8fa9ac71d54bb8753
data/exe/ice-tm CHANGED
File without changes
@@ -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
- // IDE sets these flags
16
- // speed 57600 baud; line = 0;
17
- // min = 0; time = 0;
18
- // -brkint -icrnl -imaxbel
19
- // -opost
20
- // -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
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
- else return Qfalse ;
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
- IceTM.set_baudrate(x, IceTM::BAUDRATE)
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.1)
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 = LS::Process.count
134
- ps_r = LS::Process.running.count
135
- ps_sl = LS::Process.sleeping.count
136
- ps_i = LS::Process.idle.count
137
- ps_t = LS::Process.stopped.count
138
- ps_z = LS::Process.zombie.count
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.1
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')}: No device found. Retrying#{IceTM::RESET}"
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IceTM
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_tm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami