土斯 发布的文章

反者道之动

当一个事件发展到极端 就会朝着反方向反弹,当黑暗到极点 光明就会显现,这就是反者道之动的表现,这一切的运行都遵循道,那是怎么触发这种道的机制呢,就拿食品添加剂来说,对人体的毒害是漫长的过程,当小部分人被毒害,格局还是不会变,因为他们的力量不足以 改变事态进程,当某个势力滔天的人或群体 的家人遭受添加剂毒害身亡时,他就会不顾一切反对添加剂 ,从此添加剂的命运就会终结,这种180度的转变就是道,是一个极端到不能忍受的底部就会彻底反弹趋向另外一个极端,而人类一直处于这两个极端直接徘徊 达到一种平衡 这就是太极。

昨晚 杀生了

杀了一只老鼠
扫帚柄都断了
大战七八个夜晚
掌握了逃跑路线
在逃跑路线上堵截
终于抓住了
一年本就少得可怜的德
权投进去了

本地git服务和仓库集中管理工具

使用说明

1. 本地工作区workspace
管理的是添加进来的git仓库列表,快捷方便对列表里的每个仓库进行提交和下拉操作,双击列表弹出git status信息
workspase.png
2. 路径记录
对常用目录进行添加到列表里,双击打开目录
path.png
3. 远程git服务
需要在配置里配置服务器地址和ssh用户名和密码,服务器需要安装git(apt-get install git),并手动创建/web/git目录即可
remote1.png
4. 本地git服务
可以创建本地git服务,将仓库服务器存放在本地硬盘,软件第一次打开找不到配置文件会询问本地仓库集中存放位置,后面也可以通过修改配置文件实现修改。
local.png
5. 关于
版本更新及帮助入口及配置入口
about.png
作为程序员,日积月累,工程代码太多,上传到github担心哪天被墙了,上传gitree又担心被泄露,存放本地又不好做版本管理又担心硬盘损坏,那怎么办呢,这对种种不爽,索性做一款基于git服务的代码管理集中营,集中处理每个本地仓库,本地服务,在线私服,一款软件全搞定,再也不用担心会遗忘哪个工程项目没有提交备份版本
下载 local.git.zip
配置
双击打开配置
微信截图_20220422171347.png
系统会调用记事本打开配置文件
微信截图_20220422171316.png
配置git 服务器 参数格式
用户1名@git.trtos.com@22@用户1密码?用户2名@git.trtos.com@8322@用户2密码
多个服务器 用?间隔
详见 https://www.bilibili.com/video/BV1AS4y1M78a/

直播带货有错吗!

中央好像又整治错了对象。直播带货并没有错,而且是一个值得鼓励的低成本营销方式,不该受到打击,应该大力提倡。需要整治的是化妆品和保健品行业当省去砸品牌的巨额开支是低成本和暴利。
a50f4bfbfbedab649fa3bba30cf635ca7b311ece.jpeg

一节1.5v电池供电鼠标改装锂电池供电

原生
用一节五号电池1.5v,经过鼠标内部dcdc升压到3v,方案一是用ldo将3.7v降压成3v直接接在dcdc后端,可以工作,但过一会儿就不工作了,不知道什么原因,方案二使用一颗led发光管串联降压直接接到供电焊点,3.7-1.8约等于2v经过原生dcdc降压后供鼠标工作,连续测试几天没问题,lex灯会在移动鼠标时闪烁,鼠标耗电量直接可视IMG_20211114_214156.jpg

IMG_20211114_210304.jpg

IMG_20211114_205841.jpg

IMG_20211114_210300.jpg

lua 固件更新部分 利用lua 虚拟机加载

module(...,package.seeall)

require"http"
require"misc"
require"mqtt"
require"mqttOutMsg"
require"mqttInMsg"


local torigin =
{
    SERVERIP = "182.92.223.22",
    PORT = "1883",
    DEVICEID = "7735d490-4231-11ec-8470-1bf471b2fd10",
    TOKEN = "pWIUd6QEfKl0YUqIiDFj",
}

local function writevalw(filename,value)
    local filehandle = io.open(filename,"w")
    if filehandle then
        filehandle:write(value)
        filehandle:close()
    else
        print("文件不存在或文件输入格式不正确")
    end
end
local function deletefile(filename)
    os.remove(filename)
end

newfenv = {                    
    print = function( ... )
        print(arg[1].."test")
    end
}               

--读取
local function run_file()
    local line =io.readFile("/user_main.lua")
    xpcall(function()
        local f = loadstring(line)
        setfenv(f, newfenv)  
        f()
    end,
    function() 
    print(debug.traceback())
    end
    )
end

local function cbFnc(result,prompt,head,body)
    log.info("testHttp.cbFnc",result,prompt)
    if result and head then
        for k,v in pairs(head) do
            log.info("testHttp.cbFnc",k..": "..v)
        end
    end
    if result and body then
        log.info("testHttp.cbFnc","bodyLen="..body:len())
        log.info("testHttp.cbFnc",body)
        writevalw("/user_main.lua",body)
        sys.wait(1000)
        sys.restart("下载成功软件重启")
    end
end


sys.taskInit(function()
    local retryConnectCnt = 0
    while not socket.isReady() do
            retryConnectCnt=retryConnectCnt+1
            sys.wait(1000)
            log.info("重连次数",retryConnectCnt)
            if retryConnectCnt>20 then sys.restart("程序超时软件重启") end
    end
    log.info("连接成功")
    local jsondata = json.encode(torigin)
    writevalw("/user_config.txt",jsondata)
    log.info("更新配置")
    setmetatable(newfenv,{__index = _G}) 
    run_file()
end)



-- 测试MQTT的任务代码
sys.taskInit(function()
        while not socket.isReady() do sys.wait(1000) end
        log.info("连接上网络")
        sys.wait(2000)
        local mqttc = mqtt.client(misc.getImei(),300,torigin["TOKEN"])
        log.info("连接上服务器ing")
        while not mqttc:connect(torigin['SERVERIP'], 1883) do sys.wait(2000) end
        log.info("连接上服务器")
        if mqttc:subscribe("v1/devices/me/rpc/request/+") then log.info("订阅成功") end
        local msg='{"firmware_type":"jd-iot","firmware_version": "68"}'
        log.info("sendMsg",msg)
        mqttc:publish("v1/devices/me/attributes",msg)
        while true do
            result,data = mqttc:receive(5000,"APP_SOCKET_SEND_DATA")
            if result then
                log.info("mqttInMsg.topic",data.topic)
                log.info("mqttInMsg.payload",data.payload)
                local cfgdata,result,errinfo = json.decode(data.payload)
                url=string.gsub(cfgdata['params']['pathWay'],"https://","")
                log.info("mqttInMsg.url",url)
                http.request("GET",url,nil,nil,nil,nil,cbFnc)
            end
        end
        mqttc:disconnect()
end)

lua mqtt透传部分

module(...,package.seeall)

require"utils"
require"pm"
require"sys"
require"mqtt"
require"mqttOutMsg"
require"mqttInMsg"
require "misc"
local UART_ID = 1
local mqttc22

local torigin =
{
    SERVERIP = "182.92.223.22",
    PORT = "1883",
    DEVICEID = "7735d490-4231-11ec-8470-1bf471b2fd10",
    TOKEN = "pWIUd6QEfKl0YUqIiDFj",
}
local function writevalw(filename,value)
    local filehandle = io.open(filename,"w")
    if filehandle then
        filehandle:write(value)
        filehandle:close()
    else
        print("文件不存在或文件输入格式不正确")
    end
end
local function deletefile(filename)
    os.remove(filename)
end
function split(input, delimiter,index)
    input = tostring(input)
    local pos = 0
    local i = 0
    for st,sp in function() return string.find(input, delimiter, pos, true) end do
        if (i==index) then return string.sub(input, pos, st - 1) end
        i= i + 1
        pos = sp + 1
    end
    if i==index then return string.sub(input, pos) end
    return nil
end
local function save()
    local jsondata = json.encode(torigin)
    writevalw("/user_config.txt",jsondata)
    log.info("save", "ok")
end
local function read()
    local USER_CONFIG=io.readFile("/user_config.txt")
    local cfgdata,result,errinfo = json.decode(USER_CONFIG)
    torigin=cfgdata
    log.info("save", "ok")
end
local function proc(data)
    if not data or string.len(data) == 0 then return end
    log.info("testUart.read",data)
    local a=split(data, " ",0)
    local b=split(data, " ",1)
    local c=split(data, " ",2)
    if(a=="set")
    then
        if(b=="serverip")then torigin["SERVERIP"]=c end
        if(b=="deviceid")then torigin["DEVICEID"]=c end
        if(b=="token")then torigin["TOKEN"]=c end
        uart_write(data)
    end
    if(a=="config")
    then
        if(b=="save") then save()  uart_write("save ok") end
        if(b=="read") then read()  uart_write("read  ok") end 
    end
    if(a=="print")
    then
        local jsondata = json.encode(torigin)
        log.info("jsondata", jsondata)
    end
    log.info(a,b,c)
    
end


local function read()
    local data = ""
    while true do        
        data = uart.read(UART_ID,"*l")
        if not data or string.len(data) == 0 then break end
        proc(data)
    end
end

function uart_write(s)
    log.info("testUart.write",s)
    uart.write(UART_ID,s.."\r\n")
end

local function writeOk()
    log.info("testUart.writeOk")
end


read()
pm.wake("testUart")

local port_mode=0-- 这里改成实际读取的pin脚值
if(port_mode==0) 
then
    uart.on(UART_ID,"receive",read)
    uart.on(UART_ID,"sent",writeOk)
    uart.setup(UART_ID,115200,8,uart.PAR_NONE,uart.STOP_1)
end
local revice_data=nil
local function read2()
    local data = ""
    while true do        
        data = uart.read(UART_ID,"*l")
        if not data or string.len(data) == 0 then break end
        log.info("tag", data)
        revice_data=data
    end
end


if(port_mode==1)
then
sys.taskInit(function()
    while not socket.isReady() do sys.wait(1000) log.info(".") end
    log.info("连接上网络")
    sys.wait(2000)
    mqttc2 = mqtt.client(misc.getImei(),300,torigin["TOKEN"])
    log.info("连接上服务器ing")
    while not mqttc2:connect(torigin['SERVERIP'], 1883) do sys.wait(2000) end
    log.info("连接上服务器")
    if mqttc2:subscribe("v1/devices/me/rpc/request/+") then log.info("订阅成功") end
    uart.on(UART_ID,"receive",read2)
    uart.on(UART_ID,"sent",writeOk)
    uart.setup(UART_ID,115200,8,uart.PAR_NONE,uart.STOP_1)
    while true do
        result,data = mqttc2:receive(500,"APP_SOCKET_SEND_DATA")
        if result then
            log.info("mqttInMsg.topic",data.topic)
            log.info("mqttInMsg.payload",data.payload)
            uart_write(data.payload)
        end
        if(revice_data)then
            mqttc2:publish("v1/devices/me/telemetry",revice_data)
            revice_data=nil
        end
    end
    mqttc2:disconnect()
end)
end