I can't received sms body

本文介绍如何利用Microsoft.WindowsMobile.PocketOutlook (POOM)进行短信的发送与拦截接收,并展示了具体的实现代码。作者在实践中遇到无法获取接收到的短信正文的问题,希望找出原因。

 

Send Message
using Microsoft.WindowsMobile.PocketOutlook;
SmsMessage a 
= new SmsMessage("13988888888""SmsMessage Test

a.Send();

//received sms
Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor nSms;

void nSms_MessageReceived(object sender, Microsoft.WindowsMobile.PocketOutlook.
MessageInterception.MessageInterceptorEventArgs e)
       ...
{            
           listBox21.Items.Add(a.Body);
           listBox21.Items.Add(e.Message.From.Address.ToString());
           listBox21.Items.Add(e.Message.From.Name.ToString());
           
//throw new Exception("The method or operation is not implemented.");
       }


       
private void Form1_Load(object sender, EventArgs e)
       ...
{
           nSms 
= new Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor();
           nSms.InterceptionAction 
= Microsoft.WindowsMobile.PocketOutlook.MessageInterception.Interce
ptionAction.NotifyAndDelete;
           nSms.MessageCondition.CaseSensitive 
= true;
           nSms.MessageCondition.Property 
= Microsoft.WindowsMobile.PocketOutlook.MessageInterception.
MessageProperty.Sender;
           nSms.MessageCondition.ComparisonType 
= Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessagePropertyComparisonType.Equal;
           nSms.MessageCondition.ComparisonValue 
= "13988888888";
           nSms.MessageReceived 
+= new Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventHandler(nSms_M
essageReceived);          

       }
  

 have used POOM send sms and received sms,but I can
't received sms body?why?I can't find errors in source
 code
### TCAN 函数概述 TCAN 是一种用于 CAN 总线通信的函数接口,通常在嵌入式开发环境中被广泛使用。它主要用于配置和操作 CAN 控制器,实现数据帧的发送与接收等功能。以下是关于 TCAN 函数的一些核心概念及其使用方法。 #### 1. **TCAN 函数基本语法** TCAN 的具体语法可能因不同的库或框架而有所不同,但其通用形式如下: ```c int tcan_init(TCAN_HANDLE handle, uint32_t baud_rate); int tcan_send_frame(TCAN_HANDLE handle, const struct can_frame *frame); int tcan_recv_frame(TCAN_HANDLE handle, struct can_frame *frame); ``` - `tcan_init`:初始化 CAN 接口并设置波特率。 - `tcan_send_frame`:向 CAN 总线发送一帧数据。 - `tcan_recv_frame`:从 CAN 总线上接收一帧数据[^4]。 #### 2. **TCAN 初始化示例** 下面是一个简单的 C 语言代码示例,展示如何通过 TCAN 函数初始化 CAN 设备并设置波特率为 500 kbps: ```c #include <stdio.h> #include "tcan_lib.h" #define BAUD_RATE_500K 500000 int main(void) { TCAN_HANDLE handle; // 初始化 CAN 接口 if (tcan_init(&handle, BAUD_RATE_500K) != 0) { printf("Failed to initialize CAN interface.\n"); return -1; } printf("CAN interface initialized successfully with 500kbps.\n"); // 关闭 CAN 接口 tcan_close(handle); return 0; } ``` 此代码片段展示了如何调用 `tcan_init` 来完成设备初始化,并设置了特定的波特率[^5]。 #### 3. **TCAN 数据传输示例** 以下是如何利用 TCAN 发送和接收数据的一个简单例子: ```c struct can_frame frame; // 设置要发送的数据 frame.can_id = 0x123; // 帧 ID frame.can_dlc = 8; // 数据长度码(最多 8 字节) for (int i = 0; i < 8; i++) { // 装载数据到 DLC 中 frame.data[i] = i + 1; } if (tcan_send_frame(handle, &frame) == 0) { printf("Frame sent successfully.\n"); } else { printf("Error sending frame.\n"); } // 接收数据 if (tcan_recv_frame(handle, &frame) == 0) { printf("Received Frame ID: %X\n", frame.can_id); for (int i = 0; i < frame.can_dlc; i++) { printf("Data Byte [%d]: %X\n", i, frame.data[i]); } } else { printf("No frames received or error occurred.\n"); } ``` 这段代码演示了如何构建一个标准的 CAN 帧并通过 `tcan_send_frame` 和 `tcan_recv_frame` 进行数据交互[^6]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值