From 7050da542607c5ae4bec087af125c70960302c65 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 25 Apr 2026 12:10:09 +0800 Subject: [PATCH] =?utf8?q?py=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- cat1modem/src/LeiNiao/cat1Service.py | 100 ++++++++++++++---- .../config/target_config/brandy/config.py | 4 +- 2 files changed, 80 insertions(+), 24 deletions(-) diff --git a/cat1modem/src/LeiNiao/cat1Service.py b/cat1modem/src/LeiNiao/cat1Service.py index 25c7750b3..39dad81ba 100644 --- a/cat1modem/src/LeiNiao/cat1Service.py +++ b/cat1modem/src/LeiNiao/cat1Service.py @@ -79,13 +79,13 @@ sms.setCallback(msg_cb)#sms注册回调 CAT1_SERVICE_HEAD = 'FE' #固定head PROJECT_NAME = "Cat1SlipUDPService" -PROJECT_VERSION = "PY_SRV_V30" +PROJECT_VERSION = "PY_SRV_V31" CONFIG_JSON="/usr/system_config.json" CURRENT_APP_TYPE="pysrv" - +ENABLE_CTS_RTS_PIN = 1 #设置通话音量 @@ -147,6 +147,27 @@ set_version_to_json_config(CURRENT_APP_TYPE,PROJECT_VERSION) # level - 引脚电平,int类型,0 - 设置引脚为低电平, 1- 设置引脚为高电平。 # recvDataPin = Pin(Pin.GPIO53, Pin.IN, Pin.PULL_PU, 0) +# G_gpioCTS = Pin(Pin.GPIO30, Pin.OUT, Pin.PULL_DISABLE, 1) +# cts = G_gpioCTS.read() + +# G_gpioRTS = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1) +# rts = G_gpioRTS.read() +# # clog.error('slip ',G_gpioCTS) +# clog.info('### slip cts {} rts {}'.format(cts,rts)) # args[0]:gpio号 args[1]:上升沿或下降沿 +# if cts==1 and rts==1: +# ENABLE_CTS_RTS_PIN=1 +# elif cts & rts ==0: +# ENABLE_CTS_RTS_PIN=0 +G_gpioCTS = Pin(Pin.GPIO3, Pin.IN, Pin.PULL_PD, 1) +flow_ctr = G_gpioCTS.read() +clog.info('###************************************************************* slip flow_ctr{}'.format(flow_ctr)) # args[0]:gpio号 args[1]:上升沿或下降沿 +if flow_ctr==1: + ENABLE_CTS_RTS_PIN=0 +G_gpioCTS = Pin(Pin.GPIO3, Pin.IN, Pin.PULL_DISABLE, 1) + + + + def ExtIntfun(args): # clog.info('### interrupt {} ###'.format(args)) # args[0]:gpio号 args[1]:上升沿或下降沿 if args[1] == 0: @@ -158,18 +179,31 @@ def ExtIntfun(args): pm.wakelock_unlock(lpm_fd) # pm.autosleep(1) # clog.info("recvDataPin={}".format(recvDataPin.read())) -extint = ExtInt(ExtInt.GPIO30, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, ExtIntfun) -extint.enable() - - -# 创建gpio对象 -gpioWakeBT = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1) -# 设置输入输出模式 -gpioWakeBT.set_dir(Pin.OUT) - -# 设置引脚电平 -gpioWakeBT.write(1) - +if ENABLE_CTS_RTS_PIN == 0: + extint = ExtInt(ExtInt.GPIO30, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, ExtIntfun) + extint.enable() + # 创建gpio对象 + gpioWakeBT = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1) + # 设置输入输出模式 + gpioWakeBT.set_dir(Pin.OUT) + + # 设置引脚电平 + gpioWakeBT.write(1) +else: + # 创建gpio对象 + gpioRTS = Pin(Pin.GPIO31, Pin.OUT, Pin.PULL_DISABLE, 1) + # 设置输入输出模式 + gpioRTS.set_dir(Pin.OUT) + + # 设置引脚电平 + gpioRTS.write(0) + # 创建gpio对象 + gpioCTS = Pin(Pin.GPIO30, Pin.OUT, Pin.PULL_DISABLE, 1) + # 设置输入输出模式 + gpioCTS.set_dir(Pin.OUT) + + # 设置引脚电平 + gpioCTS.write(0) UDP_CMD_GET_CAT1VER = '0' #获取 Cat1 版本号 UDP_CMD_DIAL_NUMB = '1' #拨打电话 UDP_CMD_HUNGUP = '2' #挂断电话 @@ -191,6 +225,7 @@ class Cat1Service: STA = 1 # SLIP_OUTER def __init__(self, uart=UART.UART2, mode=AP): + self.__uart = uart self.__mode = mode @@ -202,7 +237,20 @@ class Cat1Service: self.__waiting_netstat = 0 slip.destroy() clog.info('slip uart={0}'.format (self.__uart)) - ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,0) + # construct parameters: + # 1. uart: UART对象 + # 2. mode: SLIP模式 + # 3. name: 名称 + # 4. baudrate: 波特率 + # 5. data_bits: 数据位 + # 6. stop_bits: 停止位 + # 7. parity: 奇偶校验 + # 8. flow_control: 流控制 + if ENABLE_CTS_RTS_PIN == 0: + ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,0) + else: + + ret = slip.construct(self.__uart, self.__mode,'',921600,8,0,1,1) if ret != 0: clog.error('slip netif construct fail') return None @@ -859,10 +907,13 @@ class Cat1Service: try: ##self.head = head # self.content = content - gpioWakeBT.write(0) - utime.sleep_ms(2) - gpioWakeBT.write(1) - utime.sleep_ms(20) + if ENABLE_CTS_RTS_PIN == 0: + gpioWakeBT.write(0) + utime.sleep_ms(2) + gpioWakeBT.write(1) + utime.sleep_ms(20) + else: + utime.sleep_ms(20) # 消息处理 msg = self.__pack_tlv_format(head, content) @@ -888,10 +939,13 @@ class Cat1Service: def __Socket_UDP_noreply_write(self, head, content): # self.head = head # self.content = content - gpioWakeBT.write(0) - utime.sleep_ms(2) - gpioWakeBT.write(1) - utime.sleep_ms(20) + if ENABLE_CTS_RTS_PIN == 0: + gpioWakeBT.write(0) + utime.sleep_ms(2) + gpioWakeBT.write(1) + utime.sleep_ms(20) + else: + utime.sleep_ms(20) # 消息处理 msg = self.__pack_tlv_format(head, content) diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 605ee074f..aa9180080 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -1314,6 +1314,7 @@ target = { 'AUDIO_SMARTPA_AW88082', 'LCD_JD9885', 'SUPPORT_LEINIAO', + # 'SIO_UART_DISABLE_FLOW_CTRL', ], #添加自定义应用 'ram_component': [ @@ -1354,7 +1355,7 @@ target = { #VAD 相关配置 "imsl", "minimp3", - # "opus_frame_to_pcm", + # "opus_1_6_1", # "CustomUIcomponentTool", "nativeabilityfwk", "custom_utils", @@ -1368,6 +1369,7 @@ target = { # "bleservice", # "blemoder", "transspecard", + # "uarttest", # "factorytest_service", # "hid_service", # "producttest", -- 2.17.1