完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
很抱歉在我还有一个问题的时候打开一个新的问题(“我炸了我的OP AMPS吗?”)但我必须在相当短的时间内找出很多事情。
我想通过通知从我的PSoC设备向GATT客户端发送三个It16值数组。最终,我希望在GATT DB中更新这些值,用于客户端读取,但我只是尝试让通知工作。 到目前为止,我所看到的所有示例只在通知上发送了一个UtiT8值(虽然我已经看到一些代码将UTI8数组写入GATT DB),但是当我试图修改这些以与我的It16数组一起工作时,我总是得到以下警告: 从“It16(*)[ 3 ] ]分配给“Unt8*”(AKA“无符号char *”)的不兼容指针类型 我翻遍了BLE生成的代码和API文档,但是我还没有找到这个问题的解决方案。我敢肯定,这跟我不了解指针(*),地址(&;)、处理等。我想我是设置在BLE组件的自定义特性窗口的数据的类型,但我现在明白我只是改变“新字段的数据格式。” 我真的没有一个足够完整的后没有项目,但这是一段代码,我得到上面的警告。任何想法如何完成我所要做的将是最有帮助的。 谢谢, 唐 CyBLY-GATSH-HANDLYVALIONE.NTFFETT通知句柄; 如果(权重通知和0x01){ //用新数据更新通知 NoTrimeActual.AtHuffRe= WebSythCARAL句柄; NoTimeCaldLe.ValueVal=和权重数组; NoTrimeChanel.ValueLe= Weethsl CalasDATAYLLN; / /报告数据的组件通过通知发送数据 cyble_gattsnotification(cyble_connhandle,&;notificationhandle); } 以上来自于百度翻译 以下为原文 Sorry to open a new question while I still have one open ("Did I Fry my Op Amps?"), but I have to figure out quite a few things in a relatively short period of time. I want to send an array of three int16 values from my PSoC device to a GATT client via a notification. I will eventually want to update these values in the GATT DB too, for client reads, but I'm just trying to get the notifications working for now. All the examples I've seen so far only send a single uint8 value over notifications (although I have seen some code for writing a uint8 array to the GATT DB), but when I try to modify these to work with my int16 array, I always get the following warning: incompatible pointer types assigning to 'uint8*' (aka 'unsigned char *') from 'int16 (*)[3]' I've dug around in the BLE generated code and API docs, but I haven't yet found the solution to this issue. I'm pretty sure it has to do with my poor understanding of pointers (*), addresses (&), handles and so forth. I thought I was setting the type of data in the custom characteristic window of the BLE component, but I now see that I was only changing the data format of "New field." I don't really have a project complete enough to post yet, but here is a snippet of code where I am getting the above warning. Any thoughts on how to accomplish what I am trying to do would be most helpful. Thanks, Don CYBLE_GATTS_HANDLE_VALUE_NTF_T notificationHandle; if (weightsNotification & 0x01) { // update notification with new data notificationHandle.attrHandle = WEIGHTS_CHAR_HANDLE; notificationHandle.value.val = &weightsArray; notificationHandle.value.len = WEIGHTS_CHAR_DATA_LEN; // Report data to BLE component for sending data by notifications CyBle_GattsNotification(cyBle_connHandle, ¬ificationHandle); } |
|
相关推荐
17个回答
|
|
具体来说,这是我得到警告的路线…
NoTimeCaldLe.ValueVal=和权重数组; 以上来自于百度翻译 以下为原文 Specifically, this is the line where I am getting the warning... notificationHandle.value.val = &weightsArray; |
|
|
|
CAST到UIT8*与指针指向的数组的长度无关。它只表示数组的内部(例如一个条目有多长)。
以上来自于百度翻译 以下为原文 The cast to uint8* has nothing to do with the length of the array tha pointer is pointing to. It just denotes what is _inside_ of the array (e.g. how long is one entry). |
|
|
|
您可以将指针转换为值(空隙*),但在“权重数组”被声明为“类似”的情况下,可能“错误”是错误的。
UIT8加权数组[数] 然后权重数组已经是数组的地址。所以代码应该是 NoTrimeActual.ValueVal=(空虚*)权重数组; 鲍勃 以上来自于百度翻译 以下为原文 You could cast your pointer to the values into a (void*), but probably the "&" is wrong in this case when weightsArray is declared as something like uint8 weightsArray[number] Then weightsArray is already the address of the array. So the code should be notificationHandle.value.val = (void *) weightsArray; Bob |
|
|
|
因此,双栈,或至少thecyble_gatts_handle_value_ntf_t结构,希望一切都化为一系列字节的卡片吗?我只是幸运,uint8 *投了..对吧?
谢谢您。我最终会想出办法的。 以上来自于百度翻译 以下为原文 So the BLE stack, or at least the CYBLE_GATTS_HANDLE_VALUE_NTF_T structure, wants everything reduced to a series uint8 bytes? Was I just lucky that the uint8* cast got the endianness right? Thank you. I will figure this stuff out eventually. |
|
|
|
不管你用的是不是,结果都是一样的。只需使用HealthRaye返回第一个元素的地址,使用Health&HealthRayRead返回数组的地址,两者都是相同的。
但是仍然需要强制转换,因为一个It16数组和一个UIT8数组是不同的。 以上来自于百度翻译 以下为原文 It actually doesn#t matter whether you use '&' or not - the result is the same. Just using weightArray return the address of the first element, and using &weightArray return the address of the array - and both are the same. But you still need the cast, since an int16 array and a uint8 array are something different. |
|
|
|
uint8 *手段逐字节访问(一个函数时是8位,所以一个字节)。其出路,说“给我你的API,我真的不在意在那里”(除了当数据真的只是卡片的)。
字节存储顺序的不起作用的数据被从记忆的话,而另一方需要关心如何解决它。 (在我的项目中我甚至转移通知,超过256字节,但在那里的数据仅仅是uint8) 以上来自于百度翻译 以下为原文 uint8* means byte-wise access (an uint8 is 8 bits, so its one byte). Its a way for the API to say "just give me what you have, I don't really care about what in there" (except when the data really is just uint8's). Endianess doesn't play a role here - the data gets transferred from memory as it is, and the other side needs to care about how to resolve it. (In my project I even transfer more than 256 bytes in a notification, but the data in there really is just uint8) |
|
|
|
@ HLI
我学到了一些不同的东西:定义 UIT8 8MyARAL { 7〕; 然后MyArray和我的数组一样(0) 然后,MyRoad等于A&AM&MyLable { 0〕,它实际上给出指向UTI8指针的指针。 鲍勃 以上来自于百度翻译 以下为原文 @hli I've learnt something different: take the definition uint8 MyArray{7]; then MyArray is the same as &MyArray[0] &MyArray is then equal to &&MyArray{0] which actually gives a pointer to a pointer to an uint8 Bob |
|
|
|
|
|
|
|
没有冒犯的意思,但是我和我的翻译在习语中很差,你到底想说什么,Dana?
鲍勃 以上来自于百度翻译 以下为原文 No offending, but me and my translator are poor in idioms, what exactly do you mean to say, Dana? Bob |
|
|
|
所有3种类型的地址都是相同的。
指向指针的语句指针将包含一个指针。 占据了利益元素的位置? 问候,Dana。 以上来自于百度翻译 以下为原文 That the address produced for all 3 typings are the same. The statement pointer to a pointer would imply one pointer occupied the element of interest location ? Regards, Dana. |
|
|
|
事实上,我刚刚学到了“体重计”和“体重计”并不是100%当量。它们在数据类型上是不同的,前者是对单个元素(*It16)的宾特,后者是指向数组的指针(*In16[])。参见HTTP://Primult.GbDist.C.UK/CyBoo/Chord5/AlaysSyand AdAddiSsF.HTML
以上来自于百度翻译 以下为原文 Actually I just learned that 'weightArray' and '&weightArray' not 100% equivalent. They differ in their data types - the former is a pinter to a single element (*int16), the latter is a pointer to an array (*int16[]). See http://publications.gbdirect.co.uk/c_book/chapter5/arrays_and_address_of.html |
|
|
|
我承认我对GNU CC有点失望:
而不是将EN错误“无效rof”扔到一条直线上 重量表; 实际编译器接受它并将其解释为(在代码中验证)PTR=权重射线。 上述错误应该被抛出,因为“磅射线”的中间结果不存在作为可以用“&”来引用的变量。 到目前为止: 第1节:编译器总是正确的! 第2条:如果编译器不正确,则必须自动应用1 鲍勃 以上来自于百度翻译 以下为原文 And I admit that I'm a bit dissapointed about the GNU CC: instead of throwing en error "Invalid rvalue" in a line like Ptr = &weightArray; The actual compiler accepts this and interprets it as (verified in code) Ptr = weightArray The above error should be thrown because the intermediate result for "weightArray" does not exist as a variable that can be referenced with "&". OK so far: §1: The compiler is always right! §2: If compiler is not right, automatically §1 has to be applied Bob |
|
|
|
只是红色和验证HLI的职位在这里,将同意这是一个例外的正常使用的“&”-运营商(叹息,我喜欢例外)
鲍勃 以上来自于百度翻译 以下为原文 Just red and verified hli's posthere and will agree that this is an exception of the normal use of the "&"-operator (sigh, I like exceptions) Bob |
|
|
|
我喜欢一种被认为不是“强类型”的语言。
强类型的。但是在PTR算法中,文章清楚地说明了这一点。 不管怎样,它都能奏效。 问候,Dana。 以上来自于百度翻译 以下为原文 I like a language that is considered "strongly typed" that is not strongly typed. But in ptr arithmetic the article makes it clear it will work anyways. Regards, Dana. |
|
|
|
在让剩下的代码工作之后,我可以验证空洞指针(Value*)在通过FLE通知时发送It16数组的诀窍。ValueTraceHouel.ValueVar正在寻找UIT8值。我猜你可以进入生成的API代码来编辑它,但是空洞指针插入它很好。在小字节序中,我听到的是一个大小超过一个字节的值的标准,但是很好。
唐 以上来自于百度翻译 以下为原文 After getting the rest of my code to work, I can verify that the void pointer (void*) did the trick for sending int16 arrays over BLE notifications. notificationHandle.value.val was looking for uint8 values. I guess you could go into the generated API code to edit that, but the void pointer inserted it just fine. In Little Endian, which I hear is BLE standard for values more than one byte in size, but fine nonetheless. Don |
|
|
|
我必须承认使用(空洞*)是蛮力的方法。没有检查编译器所做的目标类型,只是接受并保持一致。在热测试阶段,我使用这一点,我也使用它,当我想隐藏定义(在库中)或阻碍对结构成员的访问。
我建议你,正如你已经提到的,把目标声明变成一个可比较的类型(比如指向一个IM16或Unt16数组的指针)来获得“一致性”。你没有钱,只是为了它。 鲍勃 以上来自于百度翻译 以下为原文 I have to admit that using (void *) is a brute force method. There is no checking of the target type done by the compiler, just accept and be quite. During hot testing phase I use that and I use that too, when I want to conceil definitions (in libraries) or hinder the access to structure members. I would suggest you, as you already mentioned, to change the target's declaration into a comparable type (like a pointer to an array of int16 or uint16) to get, well, "conformity". Nothing that you get money from, but just for the sake of it. Bob |
|
|
|
我想更新这个,因为答案可能很尴尬简单。
这给GATT DB带来了警告并写入了坏的值。 NoTimeCaldLe.ValueVal=和权重数组; 这是行之有效的,但正如Bob Marlowe指出的,这是一种蛮力的方法。 NoTrimeActual.ValueVal=(空虚*)权重数组; 由于NoTimeCaldLe.Value.Var需要UIT8,所以我尝试了下面的方法 NoTimeCuffel.ValueVal=(UTI8*)权重数组; PSoC 4 BLE显然有超过256个内存地址的方式,但可能有一个单独的,较小的区域专门用于GATT数据库。思想? 以上来自于百度翻译 以下为原文 I wanted to update this because the answer may have been embarrassingly simple. This threw a warning and also wrote bad values into the GATT dB notificationHandle.value.val = &weightsArray; This worked, but as Bob Marlowe pointed out, is a brute force method notificationHandle.value.val = (void*)weightsArray; Since notificationHandle.value.val wants a uint8, I tried the following and it worked notificationHandle.value.val = (uint8*)weightsArray; The PSoC 4 BLE obviously has way more than 256 memory addresses but maybe there is a separate, smaller area devoted to the GATT dB. Thoughts? |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2069 浏览 1 评论
1826 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1760 浏览 6 评论
1510 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
508浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
358浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
855浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 10:57 , Processed in 1.121032 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号