make miscchecks, skip venv

This commit is contained in:
Philippe Teuwen 2025-03-23 23:22:23 +01:00
commit 78ae375d55
5 changed files with 37 additions and 37 deletions

View file

@ -308,12 +308,12 @@ style: commands
# Make sure astyle is installed # Make sure astyle is installed
@command -v astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 ) @command -v astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 )
# Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile, *.v, pm3 # Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile, *.v, pm3
find . \( -not -path "./cov-int/*" -and -not -path "./fpga*/xst/*" -and \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" -or -name "pm3" \) \) \ find . \( -not -path "./cov-int/*" -and -not -path "./fpga*/xst/*" -and -not -path "./venv*" -and \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" -or -name "pm3" \) \) \
-exec perl -pi -e 's/[ \t]+$$//' {} \; \ -exec perl -pi -e 's/[ \t]+$$//' {} \; \
-exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \ -exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \
-exec sh -c "echo >> {}" \; -exec sh -c "echo >> {}" \;
# Apply astyle on *.c, *.h, *.cpp # Apply astyle on *.c, *.h, *.cpp
find . \( -not -path "./cov-int/*" -and \( \( -name "*.[ch]" -and -not -name "ui_overlays.h" \) -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) \) \) -exec astyle --formatted --mode=c --suffix=none \ find . \( -not -path "./cov-int/*" -and -not -path "./venv*" -and \( \( -name "*.[ch]" -and -not -name "ui_overlays.h" \) -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) \) \) -exec astyle --formatted --mode=c --suffix=none \
--indent=spaces=4 --indent-switches \ --indent=spaces=4 --indent-switches \
--keep-one-line-blocks --max-continuation-indent=60 \ --keep-one-line-blocks --max-continuation-indent=60 \
--style=google --pad-oper --unpad-paren --pad-header \ --style=google --pad-oper --unpad-paren --pad-header \
@ -343,7 +343,7 @@ miscchecks:
# Make sure recode is installed # Make sure recode is installed
@command -v recode >/dev/null || ( echo "Please install 'recode' package first" ; exit 1 ) @command -v recode >/dev/null || ( echo "Please install 'recode' package first" ; exit 1 )
@echo "Files with suspicious chars:" @echo "Files with suspicious chars:"
@find . \( -not -path "./cov-int/*" -and -not -path "./client/deps/*" -and \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" -or -name "pm3" \) \) \ @find . \( -not -path "./cov-int/*" -and -not -path "./client/deps/*" -and -not -path "./venv*" -and \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" -or -name "*.v" -or -name "pm3" \) \) \
-exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \; -exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \;
ifneq (,$(EDIT)) ifneq (,$(EDIT))
@echo "Files with tabs: (EDIT enabled, files will be rewritten!)" @echo "Files with tabs: (EDIT enabled, files will be rewritten!)"
@ -351,7 +351,7 @@ else
@echo "Files with tabs: (rerun with EDIT=1 if you want to convert them with vim)" @echo "Files with tabs: (rerun with EDIT=1 if you want to convert them with vim)"
endif endif
# to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq' # to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
@find . \( -not -path "./cov-int/*" -and -not -path "./client/deps/*" -and -not -wholename "./client/src/pm3_*wrap.c" -and \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" -or -name "pm3" \) \) \ @find . \( -not -path "./cov-int/*" -and -not -path "./client/deps/*" -and -not -path "./venv*" -and -not -wholename "./client/src/pm3_*wrap.c" -and \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" -or -name "pm3" \) \) \
-exec sh -c "$(TABSCMD)" \; -exec sh -c "$(TABSCMD)" \;
# @echo "Files with printf \\\\t:" # @echo "Files with printf \\\\t:"
# @find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \ # @find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \

View file

@ -297,7 +297,7 @@ end
function xorme(hex, xor, index) function xorme(hex, xor, index)
if ( index >= 23 ) then if ( index >= 23 ) then
--return ('%02x'):format(bxor( tonumber(hex,16) , tonumber(xor,16) )) --return ('%02x'):format(bxor( tonumber(hex,16) , tonumber(xor,16) ))
return string.format("%x", tonumber(hex,16) ~ tonumber(xor,16)) return string.format("%x", tonumber(hex,16) ~ tonumber(xor,16))
else else
return hex return hex
end end

View file

@ -111,20 +111,20 @@ local function main(args)
if o == 'h' then return help() end if o == 'h' then return help() end
end end
p:console('clear') p:console('clear')
print(dash) print(dash)
print('I am initiating the repair process for '..ac.cyan..'T5577'..ac.reset) print('I am initiating the repair process for '..ac.cyan..'T5577'..ac.reset)
io.write("Place the" .. ac.cyan .. " T5577 " .. ac.reset .. "tag on the coil and press" .. ac.green .. " ENTER " .. ac.reset .. "to continue..") io.write("Place the" .. ac.cyan .. " T5577 " .. ac.reset .. "tag on the coil and press" .. ac.green .. " ENTER " .. ac.reset .. "to continue..")
io.read() io.read()
print(dash) print(dash)
print("::: "..ac.cyan.."Hold on, I'm searching for a password in the dictionary"..ac.reset.." :::") print("::: "..ac.cyan.."Hold on, I'm searching for a password in the dictionary"..ac.reset.." :::")
print(dash) print(dash)
p:console('lf t55 chk') p:console('lf t55 chk')
local log_content = read_log_file(logfile) local log_content = read_log_file(logfile)
local password = log_content and extract_password(log_content) or nil local password = log_content and extract_password(log_content) or nil
reanimate_t5577(password) reanimate_t5577(password)
p:console('lf t55 detect') p:console('lf t55 detect')
p:console('lf t55 read -b 0') p:console('lf t55 read -b 0')
timer(5) timer(5)
local success = false local success = false
for line in p.grabbed_output:gmatch("[^\r\n]+") do for line in p.grabbed_output:gmatch("[^\r\n]+") do
if line:find("00 | 000880E0 |") then if line:find("00 | 000880E0 |") then
@ -138,7 +138,7 @@ local function main(args)
else else
print('Recovery of '..ac.cyan..'T5577'..ac.reset..' was unsuccessful !!!') print('Recovery of '..ac.cyan..'T5577'..ac.reset..' was unsuccessful !!!')
end end
print(dash) print(dash)
end end
main(args) main(args)

View file

@ -37,7 +37,7 @@ local function help()
print() print()
print(ac.yellow..' Author:'..ac.reset..author) print(ac.yellow..' Author:'..ac.reset..author)
print(ac.yellow..' Version:'..ac.reset..version) print(ac.yellow..' Version:'..ac.reset..version)
print(ac.yellow..' Modification date:'..ac.reset..mod) print(ac.yellow..' Modification date:'..ac.reset..mod)
print(desc) print(desc)
print(ac.cyan .. ' Usage' .. ac.reset) print(ac.cyan .. ' Usage' .. ac.reset)
print(usage) print(usage)
@ -175,7 +175,7 @@ local function get_uid_from_user()
local log_content = read_log_file(logfile) local log_content = read_log_file(logfile)
local uid = extract_uid(log_content) local uid = extract_uid(log_content)
if uid and #uid == 10 then if uid and #uid == 10 then
print("Readed EM4102 ID: " ..ac.green.. uid ..ac.reset) print("Readed EM4102 ID: " ..ac.green.. uid ..ac.reset)
return uid return uid
else else
io.write(ac.yellow .. "Error reading UID. Please adjust FOB position and press Enter..." .. ac.reset) io.write(ac.yellow .. "Error reading UID. Please adjust FOB position and press Enter..." .. ac.reset)

View file

@ -47,13 +47,13 @@ end
local function help() local function help()
print() print()
print(author) print(author)
print(tutorial) print(tutorial)
print(version) print(version)
print(desc) print(desc)
print(ac.cyan..' Usage'..ac.reset) print(ac.cyan..' Usage'..ac.reset)
print(usage) print(usage)
print(ac.cyan..' Arguments'..ac.reset) print(ac.cyan..' Arguments'..ac.reset)
print(arguments) print(arguments)
end end
local function reset_log_file() local function reset_log_file()
@ -265,14 +265,14 @@ local function handle_cloning(decimal_id, padded_hex_id, blocks, was_option_3)
p:console("lf hitag wrbl --ht2 -p 5 -d " .. blocks[5] .. " -k BDF5E846") p:console("lf hitag wrbl --ht2 -p 5 -d " .. blocks[5] .. " -k BDF5E846")
p:console("lf hitag wrbl --ht2 -p 6 -d " .. blocks[6] .. " -k BDF5E846") p:console("lf hitag wrbl --ht2 -p 6 -d " .. blocks[6] .. " -k BDF5E846")
p:console("lf hitag wrbl --ht2 -p 7 -d " .. blocks[7] .. " -k BDF5E846") p:console("lf hitag wrbl --ht2 -p 7 -d " .. blocks[7] .. " -k BDF5E846")
reset_log_file() reset_log_file()
--timer(5) --timer(5)
verify_written_data(blocks) verify_written_data(blocks)
elseif choice == "2" then elseif choice == "2" then
io.write(" Place the" .. ac.cyan .. " T5577 " .. ac.reset .. "tag on the coil and press" .. ac.green .. " ENTER " .. ac.reset .. "to continue..") io.write(" Place the" .. ac.cyan .. " T5577 " .. ac.reset .. "tag on the coil and press" .. ac.green .. " ENTER " .. ac.reset .. "to continue..")
io.read() io.read()
p:console("lf em 410x clone --id " .. padded_hex_id) p:console("lf em 410x clone --id " .. padded_hex_id)
print(' Cloned EM4102 to T5577 with ID ' ..ac.green.. padded_hex_id ..ac.reset) print(' Cloned EM4102 to T5577 with ID ' ..ac.green.. padded_hex_id ..ac.reset)
else else
print(ac.yellow .. " Invalid choice." .. ac.reset .. " Please enter " .. ac.cyan .. "1" .. ac.reset .. " or " .. ac.cyan .. "2" .. ac.reset) print(ac.yellow .. " Invalid choice." .. ac.reset .. " Please enter " .. ac.cyan .. "1" .. ac.reset .. " or " .. ac.cyan .. "2" .. ac.reset)
goto ask_again goto ask_again
@ -291,7 +291,7 @@ local function handle_cloning(decimal_id, padded_hex_id, blocks, was_option_3)
while true do while true do
io.write(" Enter a name for database (cannot be empty/duplicate): "..ac.yellow) io.write(" Enter a name for database (cannot be empty/duplicate): "..ac.yellow)
name = io.read() name = io.read()
io.write(ac.reset..'') io.write(ac.reset..'')
if name == nil or name:match("^%s*$") then if name == nil or name:match("^%s*$") then
print(ac.red .. ' ERROR:'..ac.reset..' Name cannot be empty.') print(ac.red .. ' ERROR:'..ac.reset..' Name cannot be empty.')
else else
@ -322,7 +322,7 @@ end
local function main(args) local function main(args)
while true do while true do
for o, a in getopt.getopt(args, 'h') do for o, a in getopt.getopt(args, 'h') do
if o == 'h' then return help() end if o == 'h' then return help() end
end end
command('clear') command('clear')
@ -349,7 +349,7 @@ local function main(args)
io.write(' Place the' .. ac.cyan .. ' Paxton' .. ac.reset .. ' Fob on the coil to read..' .. ac.green .. 'ENTER' .. ac.reset .. ' to continue..') io.write(' Place the' .. ac.cyan .. ' Paxton' .. ac.reset .. ' Fob on the coil to read..' .. ac.green .. 'ENTER' .. ac.reset .. ' to continue..')
end end
io.read() io.read()
print(dash) print(dash)
p:console('lf hitag read --ht2 -k BDF5E846') p:console('lf hitag read --ht2 -k BDF5E846')
if not logfile then if not logfile then
error(" No files in this directory") error(" No files in this directory")
@ -367,8 +367,8 @@ local function main(args)
io.write(ac.yellow .. ' Adjust the Fob position on the coil.' .. ac.reset .. ' Press' .. ac.green .. ' ENTER' .. ac.reset .. ' to continue..') io.write(ac.yellow .. ' Adjust the Fob position on the coil.' .. ac.reset .. ' Press' .. ac.green .. ' ENTER' .. ac.reset .. ' to continue..')
show_place_message = false show_place_message = false
else else
print(' Readed blocks:') print(' Readed blocks:')
print() print()
for i = 4, 7 do for i = 4, 7 do
if blocks[i] then if blocks[i] then
print(string.format(" Block %d: %s%s%s", i, ac.yellow, blocks[i], ac.reset)) print(string.format(" Block %d: %s%s%s", i, ac.yellow, blocks[i], ac.reset))
@ -430,10 +430,10 @@ local function main(args)
while retries > 0 do while retries > 0 do
io.write(' Enter the name to search ('..retries..' attempts) : '..ac.yellow) io.write(' Enter the name to search ('..retries..' attempts) : '..ac.yellow)
local user_input = io.read() local user_input = io.read()
io.write(ac.reset..'') io.write(ac.reset..'')
if user_input == nil or user_input:match("^%s*$") then if user_input == nil or user_input:match("^%s*$") then
print(ac.yellow..' Error: '..ac.reset.. 'Empty name !!!') print(ac.yellow..' Error: '..ac.reset.. 'Empty name !!!')
end end
local name_clean = "^Name:%s*" .. user_input:gsub("%s", "%%s") .. "%s*$" local name_clean = "^Name:%s*" .. user_input:gsub("%s", "%%s") .. "%s*$"
local file = io.open(log_file_path, "r") local file = io.open(log_file_path, "r")
if not file then if not file then
@ -448,7 +448,7 @@ local function main(args)
local found = false local found = false
for i = 1, #lines do for i = 1, #lines do
if lines[i]:match(name_clean) then if lines[i]:match(name_clean) then
nam = user_input nam = user_input
local blocks = { local blocks = {
[4] = lines[i + 2]:match("Block 4: (.+)"), [4] = lines[i + 2]:match("Block 4: (.+)"),
[5] = lines[i + 3]:match("Block 5: (.+)"), [5] = lines[i + 3]:match("Block 5: (.+)"),
@ -457,7 +457,7 @@ local function main(args)
} }
local em4102_id = lines[i + 6]:match("EM4102 ID: (.+)") local em4102_id = lines[i + 6]:match("EM4102 ID: (.+)")
print(dash) print(dash)
print(' I found the data under the name: '..ac.yellow ..nam.. ac.reset) print(' I found the data under the name: '..ac.yellow ..nam.. ac.reset)
for j = 4, 7 do for j = 4, 7 do
print(string.format(" Block %d: %s%s%s", j, ac.yellow, blocks[j] or "N/A", ac.reset)) print(string.format(" Block %d: %s%s%s", j, ac.yellow, blocks[j] or "N/A", ac.reset))
end end
@ -479,10 +479,10 @@ local function main(args)
print(ac.yellow .. " Name not found after 3 attempts." .. ac.reset) print(ac.yellow .. " Name not found after 3 attempts." .. ac.reset)
end end
end end
print(dash) print(dash)
print(' Exiting script Lua...') print(' Exiting script Lua...')
return return
end end
end end
main(args) main(args)