Linux rx and tx stats in /proc/tty/driver/serial file is not working - proc

I am trying to echo some string to /dev/ttyS0 and the rx and tx stats in /proc/tty/driver/serial remain 0.
If I change the irq of ttyS0 to 0 and then echo some string to ttyS0, the stats are changing according to the length of the string.
Would anyone be able to help me with this?
output of setserial -g /dev/ttyS[0123]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 11
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 10
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
output of stty -F /dev/ttyS0 -a
speed 115200 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc
out put of cat /proc/interrupts for irq 11 with 16 cpu.
11: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IO-APIC 11-edge ttyS0
output of cat /proc/tty/driver/serial:
0: uart:16550A port:000003F8 irq:11 tx:228 rx:0 RTS|DTR|DSR|CD|RI
1: uart:16550A port:000002F8 irq:10 tx:0 rx:0 CTS|DSR|CD|RI
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3
As i said I have tried to change thee irq to 0 and it worked. But what is wrong with irq 11. There is no deviced registered for irq 11 in /proc/interrupts except ttyS0.

Related

It is possible to luaj convert a script to the binary representation of lua 5.2

I am trying to convert a script to binary representation using string.dump, but I saw that the luaj 3.0.1 representation is different from lua 5.2, has some way of changing this, or turns the luaj 3.0.1 representation into lua 5.2 ?
Code
Globals _G = JsePlatform.standardGlobals();
LuaValue Function = _G.load("return string.dump(function() return 'Test' end),true);");
String Return = Function.call().toString();
Output in Hex
1B 4C 75 61 52 0 0 4 4 4 8 0 19 93 D A 1A A 0 0 0 1 0 0 0 1 0 0 2 0 0 0 3 0 0 0 1 1 0 0 1F 0 80 0 1F 0 0 0 1 4 0 0 0 5 54 65 73 74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Orientdb dosen't close tcp connections

I'm using orientdb 2.2.14 with scala. The connections aren't closed and application crashes. The following test displays the problem
val poolFactory = new OPartitionedDatabasePoolFactory()
poolFactory.setMaxPoolSize(40)
val pool = poolFactory.get("remote:db.test.com.br/mydb", "admin", "password")
val conn = pool.acquire()
try {
val query = StringBuilder.newBuilder
query.append("SELECT #this.tojson(\"fetchPlan:*:-1\") AS itens FROM Parceiro limit 1000;")
val res = conn.query[java.util.List[ODocument]](new OSQLSynchQuery[ODocument](query.toString)).asScala.toList
val result = {
if (res.isEmpty) {
None
} else {
Some(res(0).field("itens"))
}
}
result
} finally {
conn.close()
pool.close()
poolFactory.close()
}
After execute, connection stays alive. The pool close dosen't work.
netstat -ant | fgrep 2424
tcp6 0 0 :::2424 :::* LISTEN
tcp6 0 0 172.17.0.1:51928 172.17.0.1:2424 ESTABLISHED
When I do same test with postgreSQL DB the result is:
netstat -ant | fgrep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 127.0.0.1:36988 TIME_WAIT
tcp6 0 0 :::5432 :::* LISTEN

Splitting a string where one item is in parentheses

Please find my code below.
str = "1791 (AR6K Async) S 2 0 0 0 -1 2129984 0 0 0 0 0 113 0 0 20 0 1 0 2370 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 3221520956 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
for val in str:gmatch("%S+") do
print(val)
end
Output:
1791
(AR6K
Async)
S
2
0
0
0
-1
....
But I am expecting the output like,
1791
(AR6K Async)
S
2
0
0
0
-1
...
Can anyone please help me how to get the values in bracket as a single value instead getting separate values.
str = "1791 (AR6K Async) S 2 0 0 0 -1 2129984 0 0 0 0 0 113 0 0 20 0 1 0 2370 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 3221520956 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
for val in str:gsub("%S+","\0%0\0")
:gsub("%b()", function(s) return s:gsub("%z","") end)
:gmatch("%z(.-)%z") do
print(val)
end
Explanation:
1. Surround all spaceless substrings with "zero marks"
(add one binary-zero-character at the beginning and one at the end)
2. Remove "zero marks" from inside parentheses
3. Display all surrounded parts
It may not be possible to use a single lua pattern alone to do this.
However it can be easy to roll your own parsing / splitting of the string or just extend your code a bit to concatenate the parts from a part that starts with ( to the part that ends with )
Here is a small example
str = "1791 (AR6K Async) S 2 0 0 0 -1 2129984 0 0 0 0 0 113 0 0 20 0 1 0 2370 0 0 4294967295 0 0 0 0 0 0 0 2147483647 0 3221520956 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
local temp
for val in str:gmatch("%S+") do
if temp then
if val:sub(#val, #val) == ")" then
print(temp.." "..val)
temp = nil
else
temp = temp.." "..val
end
elseif val:sub(1,1) == "(" then
temp = val
else
print(val)
end
end
This code behaves exactly like your own, except that when it encounters a substring that starts with an opening bracket, it will save it to temp variable. Then it will concatenate new values to temp until a substring with the closing bracket at the end of it is encountered. At that point the whole string saved to temp will be printed and temp is set to nil and the loop is continued normally.
So there is just a special case coded for when a string with brackets comes by.
This may not be the most efficient implementation, but it works. Also this assumes that the separators are spaces, since when the strings are concatenated to temp variable, they will be concatenated with an ordinary space. This does not handle nested brackets.
This was just a quick demonstration of the idea however so I believe you can fix these shortcomings on your own as you need to if you use it.

Why is my convolution result shifted when using FFT

I'm implementing Convolutions using Radix-2 Cooley-Tukey FFT/FFT-inverse, and my output is correct but shifted upon completion.
My solution is to zero-pad both input size and kernel size to 2^m for smallest possible m, tranforming both input and kernel using FFT, then multiply the two element-wise and transform the result back using FFT-inverse.
As an example on the resulting problem:
0 1 2 3 0 0 0 0
4 5 6 7 0 0 0 0
8 9 10 11 0 0 0 0
12 13 14 15 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
with identity kernel
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
becomes
0 0 0 0 0 0 0 0
0 0 1 2 3 0 0 0
0 4 5 6 7 0 0 0
0 8 9 10 11 0 0 0
0 12 13 14 15 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
It seems any sizes of inputs and kernels produces the same shift (1 row and 1 col), but I could be wrong. I've performed the same computations using the online calculator at this link! and get same results, so it's probably me missing some fundamental knowledge. My available litterature has not helped. So my question, why does this happen?
So I ended up finding the answer why this happens myself. The answered is given through the definition of the convolution and the indexing that happens there. So by definition the convolution of s and k is given by
(s*k)(x) = sum(s(k)k(x-k),k=-inf,inf)
The center of the kernel is not "known" by this formula, and thus an abstraction we make. Define c as the center of the convolution. When x-k = c in the sum, s(k) is s(x-c). So the sum containing the interesting product s(x-c)k(c) ends up at index x. In other words, shifted to the right by c.
FFT fast convolution does a circular convolution. If you zero pad so that both the data and kernel are circularly centered around (0,0) in the same size NxN arrays, the result will also stay centered. Otherwise any offsets will add.

Search for a location in a file based on a number of spaces

What is the best way to extract the two fields (I have marked them in parenthesis) in the following line on a Linux system.
<measResults>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 311133336 325126 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10427349176 3527288 284344 439048 3582 3583 0 0 0 0 0 0 0 0 14422 14422 (311133336) 325126 (10427349176) 3527288 </measResults>
This is a single line in a *.xml file.
I am hoping some variant of grep would work but I am open to suggestions.
Are they always at the same position (i.e. after the same amount of spaces)? If so, I would use awk:
# echo "$string" | awk '{ print $51 }'
(311133336)
This should do:
awk '{print $51,$53}' <<< "$string"
(311133336) (10427349176)

Resources