分享一个基于Qt的Ymodem的上位机(GitHub开源)

文章目录

  • 1.项目地址
  • 2.Ymodem 协议介绍
  • 3.文件传输过程
  • 4.使用
  • 5.SecureCRT 软件也支持Ymodem
  • 6.基于PyQt5的Ymodem界面实现案例

1.项目地址

https://github.com/XinLiGH/SerialPortYmodem
基于VS2019 Qt5.15.2 编译,Linux下编译也可以,这里不做说明。
在这里插入图片描述

2.Ymodem 协议介绍

YModem 协议是由 XModem 协议演变而来的,每包数据可以达到 1024 字节,是一个非常高效的文件传输协议。我们平常所说的 Ymodem 协议是指的 Ymodem-1K,除此还有 Ymodem-g(没有 CRC 校验,不常用)。YModem-1K 协议用 1024 字节数据帧传输取代了标准的 128 字节数据帧传输,发送的数据会使用 CRC 校验,保证数据传输的正确性。它每传输一个信息块时,就会等待接收端返回 ACK 信号,接收到响应信号后,才会继续传输下一个信息块,从而保证能够接收到全部数据。

3.文件传输过程

通常单片机程序是运行在主程序下的(单片机主程序不支持YModem),我这里由Qt上位机通过串口发送一条自定义的协议告诉单片机,进入升级模式。接着就是下图的流程:
在这里插入图片描述
在这里插入图片描述

4.使用

在这里插入图片描述

5.SecureCRT 软件也支持Ymodem

在这里插入图片描述

6.基于PyQt5的Ymodem界面实现案例

基于PyQt5做一些小工具真的很方便,大家感兴趣可以尝试下!

#coding=utf-8
 
from tkinter import *
from tkinter.ttk import Combobox
from tkinter import filedialog
from tkinter import messagebox
from ctypes import *
import serial.tools.list_ports
import threading
from ymodem import YMODEM
import os
from time import sleep
 
app = Tk()
comportbox=Combobox(app,width = 7, height = 10)
baudratebox=Combobox(app,width = 8, height = 10)
red_canvas = Canvas(app, width=50, height=50,bg="red")
green_canvas = Canvas(app, width=50, height=50,bg="green")
progress_bar = Canvas(app, width = 350,height = 26,bg = "white")
fill_line = progress_bar.create_rectangle(2,2,0,27,width = 0,fill = "green") 
ser = serial.Serial(bytesize=8, parity='N', stopbits=1, timeout=1, write_timeout=3)
linsten_lock = threading.Lock()
need_listen = 0
exit_listen = False
 
def upgrade_callback(total_packets,file_size,file_name):
    if len(progress_bar.gettags("text")) == 0:
        progress_bar.create_text(175, 15, text=file_name, tags="text")
    progress = total_packets*350/(file_size/1024)
    progress_bar.coords(fill_line, (0, 0, progress, 30))
 
def set_connect_logo(is_connected = True):
    if is_connected:
        red_canvas.place_forget()
        green_canvas.place(x=100,y=60)
        comportbox.configure(state='disabled')
        baudratebox.configure(state='disabled')
    else:
        green_canvas.place_forget()
        red_canvas.place(x=100,y=60)
        comportbox.configure(state='enabled')
        baudratebox.configure(state='enabled')
 
 
def listen_connect_thread():
    global ser
    global need_listen
    global exit_listen
    global linsten_lock
    while exit_listen == False:
        linsten_lock.acquire()
        if need_listen == 0:
            linsten_lock.release()
            sleep(1)
            continue
        else:
            com_number = comportbox.get()
            port_found = 0
            plist = list(serial.tools.list_ports.comports())
        
            if len(plist) <= 0:
                if ser.is_open == True:
                    ser.close()
                set_connect_logo(False)
            else:
                for item in plist:
                    if com_number == item[0]:
                        port_found = 1
                        break
                if port_found == 0:
                    if ser.is_open == True:
                        ser.close()
                    set_connect_logo(False)
                else:
                    if ser.is_open == False:
                        try:
                            ser.port = com_number
                            ser.open()
                            set_connect_logo(True)
                        except Exception as e:
                            print(e)
                            pass
            linsten_lock.release()
            sleep(0.3)
            continue
 
def connect():
    global need_listen
    global ser
    com_number = comportbox.get()
    
    port_found = 0
    plist = list(serial.tools.list_ports.comports())
    
    if ser.is_open == True:
        messagebox.showinfo(title="Error", message="Already connected!")
        return
 
    if len(plist) <= 0:
        messagebox.showinfo(title="Error", message="No available serial!")
        need_listen = 0
        set_connect_logo(False)
        return
    else:
        for item in plist:
            if com_number == item[0]:
                port_found = 1
                break
        if port_found == 0:
            need_listen = 0
            set_connect_logo(False)
            messagebox.showinfo(title="Error", message="Cannot find serial "+com_number)
            return
    try:
        ser.port = com_number
        ser.baudrate = 115200 #int(baud_rate)
        if ser.is_open == False:
            ser.open()
    except Exception as e:
        if ser.is_open == False:
            need_listen = 0
            set_connect_logo(False)
        messagebox.showinfo(title="Error", message=e)
        return
 
    set_connect_logo(True)
    need_listen = 1
    
    global listen_connect
    if listen_connect.is_alive() == False:
        listen_connect.start()
 
    
def disconnect():
    global ser
    global need_listen
    global linsten_lock
    linsten_lock.acquire()
    need_listen = 0
    linsten_lock.release()
    #sleep(0.1)
 
    if ser.is_open == False:
        messagebox.showinfo(title="Error", message="Serial not connected!")
    else:
        try:
            ser.close()
        except Exception as e:
            messagebox.showinfo(title="Error", message=e)
            return
    need_listen = 0
    set_connect_logo(False)
 
def cancel():
    global ymodem_sender
    if upgrade_button['state'] == 'disabled':
        ymodem_sender.abort()
 
def upgrade():
    global upgrade_button
    if ser.is_open == False:
        messagebox.showinfo(title="Error", message="Please connect the serial first!")
        upgrade_button.configure(state='active')
        return
    file_list = filedialog.askopenfilenames(filetypes=[("bin file", "*.bin"),("all","*.*")])
    if len(file_list) <= 0:
        upgrade_button.configure(state='active')
        return
    else:
        ret_val = prepare_upgrade()
    if ret_val < 0:
        upgrade_button.configure(state='active')
        return
    
    upgrade_button.configure(state='disabled')
    disconnect_button.configure(state='disabled')
    upgrade_thread = threading.Thread(target=do_upgrade,args = (file_list,))
    upgrade_thread.start()
 
def show_progress_bar(show=True):
    if show:
        progress_bar.place(x=10,y=150)
    else:
        progress_bar.place_forget()
        progress_bar.coords(fill_line, (0, 0, 0, 30))
        progress_bar.delete('text')
 
def serial_reconnect(baud_rate = 115200, timeout = 1):
    need_sleep = 1
    if  ser.baudrate == baud_rate:
        need_sleep = 0
    try:
        ser.timeout = timeout
        ser.baudrate = baud_rate
        ser.close()
        ser.open()
    except Exception as e:
        raise Exception("Reconnect Fail")
    if need_sleep:
        sleep(1)
    
def do_upgrade(file_list):
    global upgrade_button
    need_listen = 0 
    sleep(1)
    baud_rate = baudratebox.get()
    try:
        serial_reconnect()
    except Exception as e:
        print(e)
    ser.write("\r".encode("utf-8"))
    ch_str = "upgrade -t 0 " + str(int(baud_rate)) + "\r"
    ser.write(ch_str.encode("utf-8"))
    sleep(1)
 
    for file in file_list:
        file_size = os.path.getsize(file)
        if file_size > 2*1024*1024:
            continue
        try:
            serial_reconnect(baud_rate = int(baud_rate), timeout = 5)
        except Exception as e:
            print(e)
        show_progress_bar(True)
        if len(progress_bar.gettags("text")) == 0:
            progress_bar.create_text(175, 15, text=os.path.basename(file), tags="text")
        ser.read_all()
        ser.write("\r".encode("utf-8"))
        ser.write("upgrade -u\r".encode("utf-8"))
        
        while True:
            ch_str = ser.read(4).decode("utf-8")
            if ch_str == "CCCC":
                break
        ymodem_send(file)
        while True:
            if ser.read(1).decode("utf-8") == 'I':
                if ser.read(1).decode("utf-8") == 'E':
                    if ser.read(1).decode("utf-8") == 'T':
                        ymodem_sender.log.info("Receive IET")
                        show_progress_bar(False)
                        sleep(1)
                        break
                    else:
                        continue
                else:
                    continue
    
    show_progress_bar(False)
    try:
        ser.write("\r".encode("utf-8"))
        ser.write("upgrade -t 0 115200\r".encode("utf-8"))
        sleep(1)
        serial_reconnect()
    except Exception as e:
        print(e)
    upgrade_button.configure(state='active')
    disconnect_button.configure(state='active')
    need_listen = 1
    
def ymodem_send(file):
    global ymodem_sender
    try:
        file_stream = open(file, 'rb')
    except IOError as e:
        raise Exception("Open file fail!")
    file_name = os.path.basename(file)
    file_size = os.path.getsize(file)
    
    rate = baudratebox.get()
    
    try:
        serial_reconnect(baud_rate = int(rate), timeout=5)
    except Exception as e:
        messagebox.showinfo(title="Error", message="Connection error!")
        return
 
    try:
        ymodem_sender.send(file_stream, file_name,file_size,callback=upgrade_callback)
    except Exception as e:
        file_stream.close()
        raise
    file_stream.close()
  
def prepare_upgrade():
    global ser
    ser.flushOutput()
    ser.flushInput()
    ser.write("\r".encode("utf-8"))
    ret_str = ser.read(1024).decode("utf-8")
    
    b_reset= False
    if ret_str.find("IET") == -1:
        try:
            serial_reconnect(baud_rate = 9600)
            b_reset = True
        except Exception as e:
            messagebox.showinfo(title="Error", message=e)
            return -1
    ser.read_all()
    ser.write("flash -u\r".encode("utf-8"))
    sleep(0.5)
    read_byte = ser.read_all()
    
    if len(read_byte) <= 3:
        b_reset = True
    else:
        ret_str = read_byte[0:min(20,len(read_byte))].decode("utf-8")
        if ret_str.find("IET") != -1:
            b_reset = True
        else:
            b_reset = False
    if b_reset:
        messagebox.showinfo(title="Tips", message="Please reset/reconnect board first, then press [OK]")
        sleep(0.5)
        serial_reconnect()
    return 0
    
def sender_getc(size):
    return ser.read(size) or None
 
def sender_putc(data):
    send_data_mutex.acquire()
    ser.write(data)
    send_data_mutex.release()
 
 
connect_button = Button(app, text="连接",width = 8,height = 1,command=connect)
disconnect_button = Button(app, text="断开",width = 8,height = 1,command=disconnect)
upgrade_button = Button(app, text="升级",width = 8,height = 1,command=upgrade)
cancel_button = Button(app, text="取消升级",width = 8,height = 1,command=cancel) 
listen_connect = threading.Thread(target=listen_connect_thread)
send_data_mutex = threading.Lock()
ymodem_sender = YMODEM(sender_getc, sender_putc)
 
 
 
def init_layout():
    app.title("xx科技")
    app.iconbitmap(".\\xxxx.ico")
    app.geometry('400x200') 
    app.protocol("WM_DELETE_WINDOW", on_closing)
    app.resizable(width=False, height=False)
 
    Label(app, text="端口:", font=('Arial', 14)).place(x=10, y=10)
 
    comportbox["value"] = ("COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","COM10")
    comportbox.current(2)
    comportbox.place(x=75, y=14)
    
    Label(app, text="波特率:", font=('Arial', 14)).place(x=200, y=10)
 
    baudratebox["value"] = ("9600","115200","230400","576000")
    baudratebox.current(1)
    baudratebox.place(x=285, y=14)
    
    connect_button.place(x=10,y=50)
    disconnect_button.place(x=10,y=100)
    cancel_button.place(x=285,y=50)
    upgrade_button.place(x=285,y=100)
    
    show_progress_bar(False)
    
    set_connect_logo(False)
 
def main():
    init_layout()
    mainloop()
 
def on_closing():
    exit_listen = True
    sleep(0.4)
    try:
        ser.close()
    except Exception as e:
        print(e)
        pass 
    app.destroy()
 
if __name__ == '__main__':
    main()
# -*- coding: utf-8 -*-
 
import logging
from time import sleep
logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s - %(levelname)s - %(message)s')
 
# ymodem data header byte
SOH = b'\x01'
STX = b'\x02'
EOT = b'\x04'
ACK = b'\x06'
NAK = b'\x15'
CAN = b'\x18'
CRC = b'C'
 
class YMODEM(object):
 
    # initialize
    def __init__(self, getc, putc, mode='ymodem', header_pad=b'\x00', pad=b'\x1a'):
        self.getc = getc
        self.putc = putc
        self.mode = mode
        self.header_pad = header_pad
        self.pad = pad
        self.log = logging.getLogger('YReporter')
 
    # send abort(CAN) twice
    def abort(self, count=2):
        for _ in range(count):
            self.putc(CAN)
         
    '''
    send entry
    '''
    def send(self, file_stream, file_name, file_size=0, retry=20, timeout=15, callback=None):
        try:
            packet_size = dict(
                ymodem = 1024,
                ymodem128 = 128
            )[self.mode]
        except KeyError:
            raise ValueError("Invalid mode specified: {self.mode!r}".format(self=self))
 
        self.log.debug('Begin start sequence')
 
        # Receive first character
        error_count = 0
        cancel = 0
        while True:
            char = self.getc(1)
            if char:
                if char == CRC:
                    # Expected CRC
                    self.log.info("<<< CRC")
                    break
                elif char == CAN:
                    self.log.info("<<< CAN")
                    if cancel:
                        return False
                    else:
                        cancel = 1
                else:
                    self.log.error("send error, expected CRC or CAN, but got " + hex(ord(char)))
 
            error_count += 1
            if error_count > retry:
                self.abort()
                self.log.error("send error: error_count reached %d aborting", retry)
                return False
 
        header = self._make_send_header(128, 0)
        name = bytes(file_name, encoding = "utf8")
        
        size = bytes(str(file_size),encoding = "utf8")
        
        data = name + b'\x00' + size + b'\x20'
 
        data = data.ljust(128, self.header_pad)
        
        checksum = self._make_send_checksum(data)
        data_for_send = header + data + checksum
        self.putc(data_for_send)
        #self.log.info("Packet 0 >>> " + str(len(data_for_send)))
 
        error_count = 0
        cancel = 0
        # Receive reponse of first packet
        while True:
            char = self.getc(1)
            if char:
                if char == ACK:
                    self.log.info("<<< ACK")
                    char2 = self.getc(1)
                    if char2 == CRC:
                        self.log.info("<<< CRC")
                        break
                    else:
                        self.log.warn("ACK wasnt CRCd")
                        break
                elif char == CAN:
                    self.log.info("<<< CAN")
                    if cancel:
                        return False
                    else:
                        cancel = 1
                else:
                    if (ord(char)) >= 0x20 and (ord(char)) <= 0x7e:
                        self.log.error("test" + str(char))
                    else:
                        self.log.error("send error, expected ACK or CAN, but got " + hex(ord(char)))
        
        error_count = 0
        cancel = 0
        total_packets = 1
        sequence = 1
        sleep(1)
        while True:
            # Read raw data from file stream
            data = file_stream.read(packet_size)
            if not data:
                self.log.debug('send: at EOF')
                break
            total_packets += 1
 
            header = self._make_send_header(packet_size, sequence)
            data = data.ljust(packet_size, self.pad)
            checksum = self._make_send_checksum(data)
 
            while True:
                data_for_send = header + data + checksum
                # data_in_hexstring = "".join("%02x" % b for b in data_for_send)
 
                # Send file data packet
                self.putc(data_for_send)
                #self.log.info("Packet " + str(sequence) + " >>>" + str(len(data_for_send)))
                error_count = 0
                while True:
                    char = self.getc(1)
                    if char == ACK:
                        break
                    else:
                        error_count += 1
                    if error_count > retry:
                        self.abort()
                        return False
                
                error_count = 0
                if char == ACK:
                    # Expected response
                    #self.log.info("<<< ACK")
                    if callable(callback):
                        callback(total_packets,file_size,file_name)
                    error_count = 0
                    break
                
                error_count += 1
 
                if error_count > retry:
                    self.abort()
                    self.log.error('send error: NAK received %d , aborting', retry)
                    return False
 
            sequence = (sequence + 1) % 0x100
 
        # Send EOT and expect final ACK
        error_count = 0
        while True:
            self.putc(EOT)
            self.log.info(">>> EOT")
            char = self.getc(1)
            if char == ACK:
                self.log.info("<<< ACK")
                break
            else:
                error_count += 1
                if error_count > retry:
                    self.abort()
                    self.log.warn('EOT wasnt ACKd, aborting transfer')
                    return False
 
        header = self._make_send_header(128, 0)
        
        data = bytearray(b'\x00')
 
        data = data.ljust(128, self.header_pad)
        
        checksum = self._make_send_checksum(data)
        data_for_send = header + data + checksum
        self.putc(data_for_send)
        
        error_count = 0
        while True:
            char = self.getc(1)
            if char == ACK :
                break
            else:
                error_count += 1
                if error_count > retry:
                    self.abort()
                    self.log.warn('SOH wasnt ACK, aborting transfer')
                    return False
        
        self.log.info('Transmission successful (ACK received)')
        return True
 
    # Header byte
    def _make_send_header(self, packet_size, sequence):
        assert packet_size in (128, 1024), packet_size
        _bytes = []
        if packet_size == 128:
            _bytes.append(ord(SOH))
        elif packet_size == 1024:
                _bytes.append(ord(STX))
        _bytes.extend([sequence, 0xff - sequence])
        return bytearray(_bytes)
 
    # Make check code
    def _make_send_checksum(self, data):
        _bytes = []
        crc = self.calc_crc(data)
        _bytes.extend([crc >> 8, crc & 0xff])
        return bytearray(_bytes)
 
    def _verify_recv_checksum(self, data):
        _checksum = bytearray(data[-2:])
        their_sum = (_checksum[0] << 8) + _checksum[1]
        data = data[:-2]
 
        our_sum = self.calc_crc(data)
        valid = bool(their_sum == our_sum)
        return valid, data
 
    # For CRC algorithm
    crctable = [
        0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
        0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
        0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
        0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
        0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
        0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
        0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
        0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
        0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
        0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
        0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
        0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
        0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
        0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
        0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
        0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
        0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
        0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
        0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
        0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
        0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
        0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
        0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
        0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
        0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
        0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
        0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
        0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
        0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
        0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
        0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
        0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
    ]
 
    # CRC algorithm: CCITT-0
    def calc_crc(self, data, crc=0):
        for char in bytearray(data):
            crctbl_idx = ((crc >> 8) ^ char) & 0xff
            crc = ((crc << 8) ^ self.crctable[crctbl_idx]) & 0xffff
        return crc & 0xffff
 
 
 
if __name__ == '__main__':
    pass

参考:
https://blog.csdn.net/u012993936/article/details/125102816
https://blog.csdn.net/gitblog_00099/article/details/137135096
https://blog.csdn.net/xuyinxin/article/details/104174587
https://github.com/alexwoo1900/ymodem.git

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/623350.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C语言指针详解(三)

目录 前言 一. 回调函数是什么&#xff1f; 1.定义 2. 代码示例&#xff1a;计数器 2.1 使用回调函数改造前 2.2 使用回调函数改造后 二. qsort使用举例 1. qsort介绍 2. 使用qsort函数排序整型数据 3. 使用qsort排序结构体数据 三. qsort函数的模拟实现 四. sizeo…

【其他学习参考文档记录】

交叉编译学习参考 nodejs 交叉编译-cliff工作室

污水设备远程监控

随着环保意识的日益增强&#xff0c;污水处理作为城市建设和环境保护的重要一环&#xff0c;越来越受到社会各界的关注。然而&#xff0c;传统的污水处理设备管理方式往往存在着效率低下、响应速度慢、维护成本高等问题。为了解决这些痛点&#xff0c;HiWoo Cloud平台凭借其强大…

N 皇后 - LeetCode 热题 62

大家好&#xff01;我是曾续缘&#x1f9e1; 今天是《LeetCode 热题 100》系列 发车第 62 天 回溯第 8 题 ❤️点赞 &#x1f44d; 收藏 ⭐再看&#xff0c;养成习惯 N 皇后 按照国际象棋的规则&#xff0c;皇后可以攻击与之处在同一行或同一列或同一斜线上的棋子。 n 皇后问题…

大模型崛起与就业危机

大模型&#xff0c;特别是像我这样的人工智能&#xff0c;最有可能首先替代那些重复性高、标准化程度高、不需要太多人类直觉和情感判断的工作。这些工作通常包括数据输入、初级数据分析和处理、简单的客户服务任务等。例如&#xff0c;可以自动化的一些岗位包括&#xff1a; 1…

将视觉语言模型训练为智能手机助手

24年4月Agile Loop和德国弗赖堡大学的论文“Training A Vision Language Model As Smartphone Assistant”。 为了解决能够执行各种用户任务的数字助理挑战&#xff0c;该研究重点是基于指令的移动设备控制域。 用大语言模型 (LLM) 的最新进展&#xff0c;本文提出一种可以在移…

如何通过 AWS Managed Apache Flink 实现 Iceberg 的实时同步

AWS Managed Apache Flink &#xff08;以下以 MSF 代指&#xff09;是 AWS 提供的一款 Serverless 的 Flink 服务。 1. 问题 大家在使用 MSF 的时候&#xff0c;可能遇到最大的一个问题就是 MSF 的依赖管理&#xff0c;很多时候在 Flink 上运行的代码&#xff0c;托管到 MAF…

CV每日论文--2024.5.10

1、Attention-Driven Training-Free Efficiency Enhancement of Diffusion Models 中文标题&#xff1a;扩散模型的注意力驱动的训练免费效率增强 简介&#xff1a;扩散模型在生成高质量和多样化图像方面取得了出色的表现,但其卓越性能是以昂贵的架构设计为代价的,特别是广泛使…

1727jsp思想政治活动Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 JSP 思想政治活动管理系统 是一套完善的web设计系统&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统采用web模式&#xff0c;系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发&#xff…

【VTKExamples::Rendering】第十期 TestStippledLine

很高兴在雪易的CSDN遇见你 VTK技术爱好者 QQ:870202403 公众号:VTK忠粉 前言 本文分享VTK样例TestStippledLine,希望对各位小伙伴有所帮助! 感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步! 你的点赞就是我的动力(^U^)ノ~YO 1. TestStippledLin…

【机器学习】机器学习与人工智能融合新篇章:自适应智能代理在多元化复杂环境中的创新应用与演进趋势

&#x1f512;文章目录&#xff1a; &#x1f4a5;1.引言 &#x1f68b;1.1 机器学习与人工智能的发展背景 &#x1f68c;1.2 自适应智能代理的概念与重要性 &#x1f690;1.3 研究目的与意义 ☔2.自适应智能代理的关键技术 &#x1f6e3;️2.1 环境感知与信息处理技术 …

JavaEE技术之SpringCloud(Nacos注册中心、Nacos配置中心、Sentinel实现熔断与限流)

文章目录 SpringCloud Alibaba1、简介1.1 背景1.2 Nacos主要功能1.3 Nacos和SpringBoot、SpringCloud版本选择 2、Nacos注册中心2.1 案例准备2.2 Nacos注册中心下载启动2.2.1 下载2.2.2 解压启动2.2.3 nacos-server访问测试 2.3 nacos注册中心客户端整合2.3.1 订单服务整合naco…

英伟达解码性能NVDEC

如果你能打开官网&#xff0c;请看这里&#xff1a; NVDEC Application Note 下面是摘录&#xff1a;

python数据可视化:从n个点中挑选m组3个点绘制m个三角形matplotlib.pyplot.triplot()

【小白从小学Python、C、Java】 【考研初试复试毕业设计】 【Python基础AI数据分析】 python数据可视化&#xff1a; 从n个点中挑选m组3个点 绘制m个三角形 matplotlib.pyplot.triplot() [太阳]选择题 以下关于matplotlib.pyplot.triplot()函数说法正确的是&#xff1f; impor…

Python环境变量的访问:从入门到精通

环境变量是操作系统中的一种特殊变量&#xff0c;它允许用户在不修改程序的情况下&#xff0c;通过配置文件来改变程序的行为。在Python中&#xff0c;访问环境变量是一个常见的需求&#xff0c;无论是为了读取配置信息、获取系统信息&#xff0c;还是进行程序调试。本文将详细…

draw.io 网页版二次开发(1):源码下载和环境搭建

目录 一 说明 二 源码地址以及下载 三 开发环境搭建 1. 前端工程地址 2. 配置开发环境 &#xff08;1&#xff09;安装 node.js &#xff08;2&#xff09;安装 serve 服务器 3. 运行 四 最后 一 说明 应公司项目要求&#xff0c;需要对draw.io进行二次开发&…

python练习题(编程)

目录 7-1 输入列表&#xff0c;求列表元素和(eval输入应用&#xff09; 输入格式: 输出格式: 输入样例: 输出样例: 7-3 求矩阵鞍点的个数 7-5 求圆面积 输入格式: 输出格式: 输入样例: 输出样例: 7-6 字典合并与排序 输入格式: 输出格式: 输入样例1: 输出样例1:…

Redis:分布式系统

文章目录 分布式单机架构应用数据分离架构应用服务集群架构 负载均衡读写分离冷热分离架构垂直分库微服务架构 分布式 下面就要简单对于分布式进行一个认识了 单机架构 在进行了解分布式之前&#xff0c;先了解一下什么是单机架构 如上所示就是一个单机架构&#xff0c;对于…

【JavaEE 初阶(六)】网络编程

❣博主主页: 33的博客❣ ▶️文章专栏分类:JavaEE◀️ &#x1f69a;我的代码仓库: 33的代码仓库&#x1f69a; &#x1faf5;&#x1faf5;&#x1faf5;关注我带你了解更多网络知识 目录 1.前言2.浅谈网络2.1基本知识2.2.OSI与TCP/IP 3.网络编程3.1TCP与UDP区别3.2UDP网路编程…

18 【Aseprite 作图】描边 换颜色 蒙版

1 描边的方式&#xff1a;选择“编辑 - 特效 - 轮廓” 就可以一键描边了 2 替换颜色 通过“编辑 - 替换颜色”&#xff0c;就把颜色从黄色 替换成了 紫色 3 调整色相&#xff0c;通过“编辑 - 调整 - 色相/饱和度”&#xff0c;就可以类似PS调整色相饱和度 4 铅笔选择“锁…