完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
嗨,伙计们,
我在PSoC项目中使用C++作为软件编程语言,我用PSoC Creator 3.3作为我的PSoC 4200芯片。我试着不把数据从我的BLE设备发送到手机下面的API -GT; BooIONICDATACANDRONTRONER::SENDIONICSESSATEDATA() { INT缓冲长度=0x0; NT LAST包=0x0; int MtuStudio=0x0; int i=0x0; UIT8*PTRTO缓冲器= NULL; MtuStase= GETMtusisie(); 如果(Mtusith&Lt=3) { Trace.TraceE和lt;和“无效MTU大小”; } PTRTO缓冲器=(utiN 8*)缓冲器; Trace.Tracee和lt;& lt;“ION::SENDIONICSESSIODATION数据”; 缓冲长度=StLLN((const char *)缓冲区); Mtusith-= MtuuopopeDyByl; Trace.Trace&L.;lt;“Sury::MtusiSe=”& lt;& lt;MtuSigs; LASTPACK =(缓冲长度+ MtusiS- 1)/MtuSigs; Trace. 对于(i=0;I & lt;LAST包;I++) { CHAR*PATOFDATABOUFER =新CHAR[MTUTSIZE + 1 ]; 如果(NUL= = PoPTDATABOUFER) { Trace.TraceE(&);“错误分配缓冲器”; 返回错误; } //如果成功的内存分配 MeMSET(PofDeaBoffuffER,0x0,sieZof(PoopDeabuffFER)); MeMCPY(PofDeaBoffuffER,and PttotoPuff[i*MtusiSe],siZeof(char)*MtusiSe); CyBLY-GATHAL TrAuthRoad=CyLyByFuffTxxCARIGA句柄; Fall Val.ValueVal=(Unt8*)PoopDeaBoffffER; TrLLN((const char))PoopDeaBoffuffER; (CyBygggGdBuffyStaseUs)!= CyBLY-STACK-STATENO { 聚伞花序; } 如果(cyble_gattsnotification(cyble_connhandle,&;handleval)!CyelyyeloRosiok { 示踪剂。trace() <;<;“数据包传输错误=“<;<;我; } 删除[]PopFoDaveFuffER; } 回归真实; } 你们都知道,有些手机支持的MTU大小20bytes只。现在我可以创建一个临时缓冲堆中把这些20字节的包吗?我知道我做这些的时候,数据传输的间歇。我可以看到,20个字节的前2个数据包,而其他的包不去。 在上面的代码中,我试图发送78字节的数据 现在,这意味着我要送五个20字节的数据包,假定MTU大小为23字节。 包0是成功转移 一、包成功传输后,未。 但是如果我在上面的代码片段中使用栈内存,一切正常!你知道为什么吗? 当做, 雪莉 以上来自于百度翻译 以下为原文 Hi Guys, I am using C++ in PSoC project as a software programming language and I am using PSoC Creator 3.3 for my PSoC 4200 Chip. I am trying t send the data from my BLE device to the mobile phone with the following API --> bool IonicDataController::SendIonicSessionData(){ int bufferLength = 0x0; nt lastPackage = 0x0; int mtuSize = 0x0; int i = 0x0; uint8* ptrToBuffer= NULL; mtuSize = GetMTUSize(); if(mtuSize <=3) { tracer.Trace()<<"Invalid MTU size"; } ptrToBuffer = (uint8*)buffer; tracer.Trace()<< "IONIC :: SendIonicSessionData "; bufferLength= strlen((const char*)buffer); mtuSize -= MTU_OPCODE_BYTES; tracer.Trace()<<"SHREY:: mtuSize ="< |
|
相关推荐
10个回答
|
|
|
当您上传完整的项目时,对我们来说总是更容易。
您是否将堆大小设置为0x0200(在系统视图中)? PSoC Creator 3.3岁很老,有点落伍了。我强烈建议您升级到当前版本,此时为4.2(与V3.3共存) 鲍勃 以上来自于百度翻译 以下为原文 It is always easier for us when you upload your complete project. Did you set the heap size to something like 0x0200 (in System view)? PSoC Creator 3.3 is very old and partly outdated. I strongly suggest you to upgrade to current version which is 4.2 at this time (co-existent with v3.3) Bob |
|
|
|
|
ncmza 发表于 2018-9-29 11:33 嗨,鲍勃马洛 我不能真正上传我的整个项目,因为它更机密。我知道我已经启用了堆。 闪存使用:262144字节(234240)中的89.4%个。Bootloader:16384字节。应用程序:217600字节。元数据:256字节。 SRAM使用:32768个字节中的28796个(87.9%)。堆栈:2048字节。堆:2048字节。 我可以理解和下载PSoC创建者4.2,但我的项目是彻底测试与PSoC Creator 3.3,并接近启动,我不想冒风险,通过迁移到一个新的创建者版本。 基本上,当我在下面的片段中传递一个动态分配的缓冲区时,我会遇到问题。数据传输并不像预期的那样发生。 CyLay-GalthAtHyLeValueApHyth.AdvalValman;Advalv.AtHuff句柄= CyLyByFultTxxCARYA句柄;Hoalval.Value.Val= =(Unt8*)PoopDeaBuffFER;Hoalval.Value.Le= StLLEN((const char)PoopDeaBoffuffER); 以上来自于百度翻译 以下为原文 Hi bob.marlowe I cannot really upload my entire project here as it is more confidential. I see that I have enabled the Heap. Flash used: 234240 of 262144 bytes (89.4 %). Bootloader: 16384 bytes. Application: 217600 bytes. Metadata: 256 bytes.I can understand and download PSoC creator 4.2, however my project is thoroughly tested with PSoC Creator 3.3 and close to the launch I don't want to risk it by migrating it to a new Creator version. Basically when I pass a dynamically allocated buffer in the snippet below, I am getting problems. The data transfer doesn't really happen as expected
|
|
|
|
|
dfzvzs 发表于 2018-9-29 11:44 我还看到在PSoC创建者中不支持标准的C++新的和免费的。 所以我不得不即兴表演 特征函数动态支持 Value*new new [](SiZeSt大小) { 返回MALLC(大小); } 无效运算符删除[](空隙*PTR) { 自由(PTR); } 第二节 以上来自于百度翻译 以下为原文 I also see that the standard C++ new and free is not supported in PSoC creator So I have to sort of improvise #ifdef FEATURE_DYNAMIC_MTU_SUPPORTvoid * operator new[](size_t size){ return malloc(size);}void operator delete[](void * ptr){ free(ptr);}#endif |
|
|
|
|
|
我看不到一见钟情。 鲍勃 以上来自于百度翻译 以下为原文 I cannot see anything wrong at first sight. Bob |
|
|
|
|
|
令人惊讶的是,一旦我在堆栈中建立缓冲区,一切都会起作用。 BooIONICDATACANDRONTRONER::SENDIONICSESSATEDATA() { 特征函数动态支持 INT缓冲长度=0x0; int LAST包=0x0; int MtuStudio=0x0; int i=0x0; UIT8*PTRTO缓冲器= NULL; MtuStase= GETMtusisie(); 如果(Mtusith&Lt=3) { Trace.TraceE和lt;和“无效MTU大小”; } PTRTO缓冲器=(uTIN 8*)缓冲器; Trace.Tracee和lt;& lt;“ION::SENDIONICSESSIODATION数据”; 缓冲长度=StLLN((const char *)缓冲区); Mtusith-= MtuuopopeDyByl; LASTPACK =(缓冲长度+ MtusiS- 1)/MtuSigs; 对于(i=0;I & lt;LAST包;I++) { 焦partofdatabuffer [ mtusize + 1 ]; memset(partofdatabuffer,0x0,sizeof(partofdatabuffer)); MeMCPY(PofDeaBoffuffER,and PttotoPuff[i*MtusiSe],siZeof(char)*MtusiSe); cyble_gatt_handle_value_pair_t handleval; handleval.attrhandle = cyble_feed_tx_char_handle; handleval.value.val =(uint8 *)partofdatabuffer; handleval.value.len = strlen((const char *)partofdatabuffer); 而(cyble_gattgetbusystatus()!= CyBLY-STACK-STATENO { 聚伞花序; } 如果(CyBLY-GATS通知)(CyByLyCouthRead,& and Hand Leavar)!CyelyyeloRosiok { Trace.TraceE(&);和lt;“分组传输错误=”& lt;& lt;I; } } 回归真实; 第二节 } 我不知道为什么会这样。 问候,Shrey 以上来自于百度翻译 以下为原文 The surprising part is as soon as I make the buffer in STACK, everything works bool IonicDataController::SendIonicSessionData(){#ifdef FEATURE_DYNAMIC_MTU_SUPPORT int bufferLength = 0x0; int lastPackage = 0x0; int mtuSize = 0x0; int i = 0x0; uint8* ptrToBuffer= NULL; mtuSize = GetMTUSize(); if(mtuSize <=3) { tracer.Trace()<<"Invalid MTU size"; } ptrToBuffer = (uint8*)buffer; tracer.Trace()<< "IONIC :: SendIonicSessionData "; bufferLength= strlen((const char*)buffer); mtuSize -= MTU_OPCODE_BYTES; lastPackage = (bufferLength + mtuSize - 1)/mtuSize; for(i=0; i |
|
|
|
|
dfzvzs 发表于 2018-9-29 12:38 我不确定,但是我认为动态内存分配在PSoC Creator中不起作用吗?我尝试了一次,碰到了一个无法分配/释放内存的墙。下面的编译器是GNU/GCC编译器,所以我希望它能工作,但是我认为PSoC Creator覆盖了非编译时间常数函数/内存,它阻止了MalOCs的工作。 这将解释为什么将缓冲区分配给堆栈工作。 以上来自于百度翻译 以下为原文 I'm not sure, but I think dynamic memory allocation doesn't work in the PSoC Creator? I tried it at one point and ran into a wall of being unable to allocate/deallocate memory. The compiler underneath is the GNU/GCC compiler, so I would expect it to work, but I think the PSoC Creator overrides non-compile-time constant functions/memory which prevents mallocs from working. That would explain why allocating your buffers to the stack works... |
|
|
|
|
yuhe82 发表于 2018-9-29 12:55 我写了一个运行在PSoC4上的RTOS,使用大量的MalCube()和For()。只有SaveFF()与浮动不起作用… 鲍勃 以上来自于百度翻译 以下为原文 I wrote an RTOS running on PSoC4 using lots of malloc() and free(). Only sprintf() with floats didn't work... Bob |
|
|
|
|
yuhe82 发表于 2018-9-29 12:55 E.普拉特1616216 堆工作和CyPress PSoC上的内存分配也为我们提供了使用C++定义的函数来创建C++中的新()和DeleTeE()运算符的能力,如下面的代码片段所示。 特征函数动态支持 Value*new new [](SiZeSt大小) { 返回MALLC(大小); } 无效运算符删除[](空隙*PTR) { 自由(PTR); } 第二节 然而,我的问题是,当我把这个缓冲器传递给BLE控制器时,数据传输不会完全发生。例如,如果我有20字节的MTU大小,并且我说要传输10个数据包,我只能传输2个数据包,而REST不传输。但是,如果在堆栈上分配内存,然后将该缓冲器传递给BLE控制器,那么传输就如预期的那样工作。我不确定内部(硬件方面),如果BLE控制器对内存堆有一种有限的内存访问。或者在总线上有一个bug,在某个时候访问丢失。 以上来自于百度翻译 以下为原文 e.pratt_1639216 The memory allocation on the heap works and Cypress PSoC also provides the capability for us to create new() and delete() operator in C++ using a user defined function as is shown in the below snippet. #ifdef FEATURE_DYNAMIC_MTU_SUPPORTvoid * operator new[](size_t size) { return malloc(size); } void operator delete[](void * ptr) { free(ptr); }#endif My problem however is when I pass this buffer to BLE controller, the data transfer doesn't happen completely. For example if I have MTU size of 20 bytes and I have say 10 packets to transfer, I can only transfer 2 packets and rest doesn't transfer. However if I allocate the memory on Stack and then pass that buffer to BLE controller, then the transfers work as expected. I am not sure internally (hardware side) if the BLE controller has some sort of limited memory access to HEAP memory or not. Or there is some bug in the bus that the access is lost after sometime. |
|
|
|
|
|
鲍勃马洛 你是正确的,MalCube()和CalCurror()和For()函数起作用。我的问题是,当我通过使用BLE控制器创建的内存时,数据传输变得非常断断续续。 以上来自于百度翻译 以下为原文 bob.marlowe You are right malloc() and calloc() and free() functions work. My problem with this is just that when I pass the memory created using this to BLE controller, the data transfers become highly intermittent. |
|
|
|
|
|
嗯,不知道我为什么在那之前遇到麻烦。 以上来自于百度翻译 以下为原文 Hmmm; Not sure why I ran into trouble with it before then |
|
|
|
|
只有小组成员才能发言,加入小组>>
786个成员聚集在这个小组
加入小组cyUSB3014一直显示2.1,不能到3.0情况,谁遇到过
7241 浏览 0 评论
2482 浏览 1 评论
2175 浏览 1 评论
4037 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
2082 浏览 6 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
7724浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
6283浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
751浏览 2评论
725浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
8119浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-8 16:37 , Processed in 0.985051 second(s), Total 92, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2588