完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在处理的数据在线下时都是无符号的,所以我认为没有任何负面因素可以处理。谢谢警告,我是否应该重复使用该代码.-- Graeme HiltonR& D EngineerSchlumberger SensaBill Ossmann
在02/11/2005 16:25写了以下内容:>我不知道你是否必须处理负数,但如果你这样做>认为该公式将导致int16的整数溢出,或者不给予> 作为int32的预期2的补充。> - > Bill Ossmann> Philips Ultrasound>电子邮件:bill.ossmann@philips.com >> Graeme Hilton于11/02/2005 10:00:12 AM撰写:> >> 谢谢Dave,>>>>我不得不捏一点让这个接受我的数据,但它的工作效果很好。>>但是,我在套接字读数上坚持了一点,然后来了>> >> >>来自Socket,READ BINARY x BYTE ARRAY:16001,2 >>然后一个公式:(x [*,1] * 256 + x [*,0])将两列>>字节结合在一起。>> >>非常快速而且非常简单。>>>> - >> Graeme Hilton >> R& D工程师>>>> Schlumbe rger Sensa >>>>>> David Watling在02/11/2005 14:08写了以下内容:>>>您好Graeme,>>>我写了一个byteswop公式,它适用于>>>的所有元素元素 。 将数组加载为INT16,然后运行swopper功能。 您也可以>>>或者也可能不想要2的cmpl函数。>>>>>>函数byteswop int16:>>> bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A) ,8),#Hff00)); >>>>>> 2的cmpl >>> asInt16(A-(A DIV 32768)* 65536); >>>>>>>>>问候>>>>>>大卫 Watling >>>>>> -----原帖----- >>>来自:Graeme Hilton [mailto:GHilton@slb.com] >>>发送日期:2005年11月2日13:43 >>>至 :VRF >>>主题:[vrf]字节数组转换为int16s数组>>>>>>大家好,>>>>>>这是我的最新谜题; >>>>>>我正在读取数据 TCP / IP套接字。 我读了32002个字节,其中>>>代表>>> 16001个16位整数。 我不能使用READ BINARY x INT16 ARRAY1D >>> 16001,因为>>>数据首先显示为LSB,而To / From Socket对象>假设>>>它是>>> MSB优先。>>>>> >要将这些数字拼接在一起,我将执行以下操作:>>> For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建我的>>> int16> >> 16001元素的数组。>>>>>>我的问题是这需要花费大量的时间(与>>>其余的>>>相比)。 有没有人有这样做的非循环方式或>>>另一种>>>节省时间的方法?>>>>> --- >> 以上来自于谷歌翻译 以下为原文 The data I'm dealing with is all unsigned when it comes off the wire, so I assume there are no negatives to deal with there. Thanks for the warning, should I ever reuse that code. -- Graeme Hilton R&D Engineer Schlumberger Sensa Bill Ossmann wrote the following on 02/11/2005 16:25: > I don't know if you have to deal with negative numbers, but if you do I > think that formula will cause an integer overflow for an int16, or not give > the expected 2's complement as an int32. > -- > Bill Ossmann > Philips Ultrasound > e-mail: bill.ossmann@philips.com > > Graeme Hilton wrote on 11/02/2005 10:00:12 AM: > >> Thanks Dave, >> >> I had to fiddle a little to get this to accept my data, but it works > well. >> However, I persevered a little more with the socket reading and came >> up with this: >> >> From Socket, READ BINARY x BYTE ARRAY:16001,2 >> Then a formula: (x[*,1]*256+x[*,0]) to marry the two columns of >> bytes together. >> >> Very quick and very simple. >> >> -- >> Graeme Hilton >> R&D Engineer >> >> Schlumberger Sensa >> >> >> David Watling wrote the following on 02/11/2005 14:08: >>> Hi Graeme, >>> I wrote a byteswop formula which works on all elements of the array at >>> once. Load the array as INT16, then run the swopper function. You may >>> or may not want the 2's cmpl function as well. >>> >>> Function byteswop int16: >>> bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)); >>> >>> 2's cmpl >>> asInt16(A-(A DIV 32768)*65536); >>> >>> >>> Regards >>> >>> David Watling >>> >>> -----Original Message----- >>> From: Graeme Hilton [mailto:GHilton@slb.com] >>> Sent: 02 November 2005 13:43 >>> To: VRF >>> Subject: [vrf] Array of bytes convert to array of int16s >>> >>> Hi All, >>> >>> Here's my latest puzzle; >>> >>> I am reading data from a TCP/IP socket. I read 32002 bytes which >>> represent >>> 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D >>> 16001 as the >>> data is presented as LSB first whereas the To/From Socket object > assumes >>> it's >>> MSB first. >>> >>> To stitch these numbers together I run through the following: >>> For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my >>> int16 >>> array of 16001 elements. >>> >>> My problem is that this takes a significant amount of time (compared to >>> the rest >>> of the program). Does anyone have a non-looping way of doing this or >>> another >>> time-saving method? >>> >> --- |
|
相关推荐
7个回答
|
|
>数据首先显示为LSB>而To / From Socket对象>首先假设它是MSB。我的!
好吧,是的,我可以想到一个更快的方法,但我认为更大的问题是,无论发送数据是什么都不正确! 网络字节顺序发布为对应用程序层透明。 IOW,htons()首先没有使用。基本上,只需将字节移动到一个Int16数组中。 如果没有其他解决方案在同一时间呈现,我会详细说明当我从今天的小方向回来。-SHAWN ----您目前订阅vrf为:r***@soco.agilent.com要订阅发送空白电子邮件至“ join-vrf@it.lists.it.agilent.com“。要取消订阅,请发送一封空白电子邮件至”leave-vrf@it.lists.it.agilent.com“。要发送邮件到此邮件列表,请发送电子邮件至”vrf @“ agilent.com”。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 > the data is presented as LSB first > whereas the To/From Socket object > assumes it's MSB first. Oh my! Well, yes I can think of a faster way but I think the larger problem is that whatever is sending the data is incorrect! Network byte order is supposed to be transparent to the application layer. IOW, htons() was not used in the first place. Basically, just move the bytes into an Int16 array en masse. I'll elaborate when I get back from today's little side track if no other solution presents itself in the mean time. -SHAWN- --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
我不知道你是否必须处理负数,但如果你这样做,我认为该公式会导致int16的整数溢出,或者不会将预期的2的补码作为int32 .-- Bill OssmannPhilips Ultrasounde-mail:bill。
ossmann@philips.comGraeme希尔顿写于11/02/2005 10:00:12 AM:>谢谢Dave,>>我不得不捏一点让这个接受我的数据,但它仍然有效。>>但是,我坚持了下来 再看一下套接字读数,然后来了:>>来自Socket,READ BINARY x BYTE ARRAY:16001,2>然后一个公式:(x [*,1] * 256 + x [*,0]) 结合两个>字节的列。>>非常快速和简单。>> - > Graeme Hilton> R& D工程师>> Schlumberger Sensa >>> David Watling在02/11/2005 14上写了以下内容: 08:>>你好Graeme,>>我写了一个byteswop公式,它可以在>>一次对数组的所有元素起作用。 将数组加载为INT16,然后运行swopper功能。 您可能>>或者也可能不想要2的cmpl函数。> >>>函数byteswop int16:>> bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8), #Hff00));> >>> 2的cmpl >> asInt16(A-(A DIV 32768)* 65536);> >> >>>问候> >>> David Watling> >>> -----原始信息 ----->>来自:Graeme Hilton [mailto:GHilton@slb.com]>>发送时间:2005年11月2日13:43 >> To:VRF >>主题:[vrf]字节数组转换为int16s数组 > >>>大家好,> >>>这是我最新的谜题;> >>>我正在从TCP / IP套接字读取数据。 我读取32002个字节,>>代表>> 16001 16位整数。 我不能使用READ BINARY x INT16 ARRAY1D >> 16001,因为>>数据首先显示为LSB,而To / From Socket对象通常>>它的>> MSB优先。> >>>将这些数字拼接在一起我运行 通过以下内容:>> For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建我的>> int16 >> 16001元素数组。> >>> 我的问题是这需要花费大量的时间(相比于>>其余的>程序)。 有没有人有一个非循环的方式这样做或>>另一个>节省时间的方法?> >>> --->您目前订阅vrf为:bill.ossmann@philips.com>订阅发送一个 空白电子邮件至“join-vrf@it.lists.it.agilent.com”。>要取消订阅,请发送空白电子邮件至“leave-vrf@it.lists.it.agilent.com”。>发送邮件至此邮件 列表,请发送电子邮件至“vrf@agilent.com”。>如果您需要有关邮件列表的帮助,请发送邮件至“owner-> vrf@it.lists.it.agilent.com”。>搜索“非官方vrf档案”, “www.oswegosw.com/vrf_archive/".---您目前订阅了vrf:r***@soco.agilent.com要订阅,请发送空白电子邮件至”join-vrf@it.lists.it.agilent.com“ 。要取消订阅,请发送空白电子邮件至“leave-vrf@it.lists.it.agilent.com”。要向此邮件列表发送邮件,请发送电子邮件至“vrf@agilent.com”。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 I don't know if you have to deal with negative numbers, but if you do I think that formula will cause an integer overflow for an int16, or not give the expected 2's complement as an int32. -- Bill Ossmann Philips Ultrasound e-mail: bill.ossmann@philips.com Graeme Hilton wrote on 11/02/2005 10:00:12 AM: > Thanks Dave, > > I had to fiddle a little to get this to accept my data, but it works well. > > However, I persevered a little more with the socket reading and came > up with this: > > From Socket, READ BINARY x BYTE ARRAY:16001,2 > Then a formula: (x[*,1]*256+x[*,0]) to marry the two columns of > bytes together. > > Very quick and very simple. > > -- > Graeme Hilton > R&D Engineer > > Schlumberger Sensa > > > David Watling wrote the following on 02/11/2005 14:08: > > Hi Graeme, > > I wrote a byteswop formula which works on all elements of the array at > > once. Load the array as INT16, then run the swopper function. You may > > or may not want the 2's cmpl function as well. > > > > Function byteswop int16: > > bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)); > > > > 2's cmpl > > asInt16(A-(A DIV 32768)*65536); > > > > > > Regards > > > > David Watling > > > > -----Original Message----- > > From: Graeme Hilton [mailto:GHilton@slb.com] > > Sent: 02 November 2005 13:43 > > To: VRF > > Subject: [vrf] Array of bytes convert to array of int16s > > > > Hi All, > > > > Here's my latest puzzle; > > > > I am reading data from a TCP/IP socket. I read 32002 bytes which > > represent > > 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D > > 16001 as the > > data is presented as LSB first whereas the To/From Socket object assumes > > it's > > MSB first. > > > > To stitch these numbers together I run through the following: > > For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my > > int16 > > array of 16001 elements. > > > > My problem is that this takes a significant amount of time (compared to > > the rest > > of the program). Does anyone have a non-looping way of doing this or > > another > > time-saving method? > > > > --- > You are currently subscribed to vrf as: bill.ossmann@philips.com > To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". > To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". > To send messages to this mailing list, email "vrf@agilent.com". > If you need help with the mailing list send a message to "owner- > vrf@it.lists.it.agilent.com". > Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
大家好,这是我最新的谜题;我正在从TCP / IP套接字读取数据。
我读取32002个字节,代表16001个16位整数。 我不能使用READ BINARY x INT16 ARRAY1D 16001,因为数据首先显示为LSB而To / From Socket对象假定它是MSB优先。要将这些数字拼接在一起,我将执行以下操作:For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建我的1616个元素的int16数组。我的问题是这需要花费大量时间(与程序的其余部分相比)。 有没有人采用非循环方式做到这一点或另一种节省时间的方法? - Graeme HiltonR& D EngineerSchlumberger Sensa ---您目前订阅了vrf:r***@soco.agilent.com要订阅,请发送空白电子邮件至 “join-vrf@it.lists.it.agilent.com”。要取消订阅,请发送一封空白电子邮件至“leave-vrf@it.lists.it.agilent.com”。要向此邮件列表发送邮件,请发送电子邮件至“vrf” @ agilent.com”。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 Hi All, Here's my latest puzzle; I am reading data from a TCP/IP socket. I read 32002 bytes which represent 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D 16001 as the data is presented as LSB first whereas the To/From Socket object assumes it's MSB first. To stitch these numbers together I run through the following: For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my int16 array of 16001 elements. My problem is that this takes a significant amount of time (compared to the rest of the program). Does anyone have a non-looping way of doing this or another time-saving method? -- Graeme Hilton R&D Engineer Schlumberger Sensa --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
大家好,这是我最新的谜题;我正在从TCP / IP套接字读取数据。
我读取32002个字节,代表16001个16位整数。 我不能使用READ BINARY x INT16 ARRAY1D 16001,因为数据首先显示为LSB而To / From Socket对象假定它是MSB优先。要将这些数字拼接在一起,我将执行以下操作:For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建我的1616个元素的int16数组。我的问题是这需要花费大量时间(与程序的其余部分相比)。 有没有人采用非循环方式做到这一点或另一种节省时间的方法? - Graeme HiltonR& D EngineerSchlumberger Sensa ---您目前订阅了vrf:r***@soco.agilent.com要订阅,请发送空白电子邮件至 “join-vrf@it.lists.it.agilent.com”。要取消订阅,请发送一封空白电子邮件至“leave-vrf@it.lists.it.agilent.com”。要向此邮件列表发送邮件,请发送电子邮件至“vrf” @ agilent.com”。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 Hi All, Here's my latest puzzle; I am reading data from a TCP/IP socket. I read 32002 bytes which represent 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D 16001 as the data is presented as LSB first whereas the To/From Socket object assumes it's MSB first. To stitch these numbers together I run through the following: For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my int16 array of 16001 elements. My problem is that this takes a significant amount of time (compared to the rest of the program). Does anyone have a non-looping way of doing this or another time-saving method? -- Graeme Hilton R&D Engineer Schlumberger Sensa --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
嗨Graeme,我写了一个byteswop公式,它适用于数组atonce的所有元素。
将数组加载为INT16,然后运行swopper功能。 你可能也不想要2的cmpl函数。函数byteswop int16:bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)); 2的cmplasInt16(A - (A DIV 32768)* 65536); RegardsDavid Watling -----原始信息-----来自:Graeme Hilton [mailto:GHilton@slb.com]发送时间:2005年11月2日13:43T:VRFSubject:[vrf ]字节数组转换为int16sHi数组全部,这是我最新的谜题;我正在从TCP / IP套接字读取数据。 我读取32002个字节,代表16001个16位整数。 我不能使用READ BINARY x INT16 ARRAY1D16001,因为数据首先显示为LSB而To / From Socket对象首先假设MSB。要将这些数字拼接在一起,我将执行以下操作:For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建16001个元素的myint16数组。我的问题是这需要花费大量时间(与程序的其余部分相比)。 有没有人采用非循环的方式来实现这种省时省力的方法? - Graeme HiltonR& D EngineerSchlumberger Sensa ---您目前订阅了vrf:watling@icerasemi.com要订阅,请发送空白电子邮件至“加入 - vrf@it.lists.it.agilent.com“。要取消订阅,请发送一封空白电子邮件至”leave-vrf@it.lists.it.agilent.com“。要发送邮件到此邮件列表,请发送电子邮件至”vrf @ agilent。 COM”。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”.--- 您目前订阅了vrf:r***@soco.agilent.com要订阅,请发送一封空白电子邮件至“join-vrf@it.lists.it.agilent.com”。要取消订阅,请发送空白电子邮件至“leave-vrf @ it .lists.it.agilent.com“。要发送邮件到这个邮件列表,请发送电子邮件至”vrf@agilent.com“。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 Hi Graeme, I wrote a byteswop formula which works on all elements of the array at once. Load the array as INT16, then run the swopper function. You may or may not want the 2's cmpl function as well. Function byteswop int16: bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)); 2's cmpl asInt16(A-(A DIV 32768)*65536); Regards David Watling -----Original Message----- From: Graeme Hilton [mailto:GHilton@slb.com] Sent: 02 November 2005 13:43 To: VRF Subject: [vrf] Array of bytes convert to array of int16s Hi All, Here's my latest puzzle; I am reading data from a TCP/IP socket. I read 32002 bytes which represent 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D 16001 as the data is presented as LSB first whereas the To/From Socket object assumes it's MSB first. To stitch these numbers together I run through the following: For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my int16 array of 16001 elements. My problem is that this takes a significant amount of time (compared to the rest of the program). Does anyone have a non-looping way of doing this or another time-saving method? -- Graeme Hilton R&D Engineer Schlumberger Sensa --- You are currently subscribed to vrf as: watling@icerasemi.com To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
这是一个big-endian little-endian问题.Motorola芯片使用Big-endianIntel芯片使用Little-endian一些信息:http://www.cs.umass.edu/~verts/cs32/endian.htmlDave Watling -----
原始消息-----来自:Shawn Fessenden [mailto:shawn@testech-ltd.com]发送时间:2005年11月2日14:31:VRFSubject:RE:[vrf]字节数组转换为int16s数组>数据是 首先呈现为LSB>而To / From Socket对象>首先假设它是MSB。我的! 嗯,是的,我可以想到一个更快的方式,但我认为更大的问题是,无论发送数据是什么都不正确! 网络字节顺序发布为对应用程序层透明。 IOW,htons()首先没有被使用。基本上,只需将字节移动到一个Int16数组中。 如果没有其他解决方案在同一时间出现,我会从今天的小方向回来。-SHAWN ----您目前订阅了vrf:watling@icerasemi.com要订阅,请发送空白电子邮件至“join-vrf @ it.lists.it.agilent.com“。要取消订阅,请发送一封空白电子邮件至”leave-vrf@it.lists.it.agilent.com“。要发送邮件至此邮件列表,请发送电子邮件至”vrf@agilent.com“ 。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”.--- 您目前订阅了vrf:r***@soco.agilent.com要订阅,请发送一封空白电子邮件至“join-vrf@it.lists.it.agilent.com”。要取消订阅,请发送空白电子邮件至“leave-vrf @ it .lists.it.agilent.com“。要发送邮件到这个邮件列表,请发送电子邮件至”vrf@agilent.com“。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 This is a big-endian little-endian issue. Motorola chips use Big-endian Intel chips use Little-endian Some info: http://www.cs.umass.edu/~verts/cs32/endian.html Dave Watling -----Original Message----- From: Shawn Fessenden [mailto:shawn@testech-ltd.com] Sent: 02 November 2005 14:31 To: VRF Subject: RE: [vrf] Array of bytes convert to array of int16s > the data is presented as LSB first > whereas the To/From Socket object > assumes it's MSB first. Oh my! Well, yes I can think of a faster way but I think the larger problem is that whatever is sending the data is incorrect! Network byte order is supposed to be transparent to the application layer. IOW, htons() was not used in the first place. Basically, just move the bytes into an Int16 array en masse. I'll elaborate when I get back from today's little side track if no other solution presents itself in the mean time. -SHAWN- --- You are currently subscribed to vrf as: watling@icerasemi.com To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
谢谢戴夫,我不得不捏一点让这个接受我的数据,但是效果很好。但是,我在套接字读数上坚持了一点,想出了这个:来自Socket,READ BINARY x BYTE ARRAY:16001,
2然后一个公式:(x [*,1] * 256 + x [*,0])将两列字节结合在一起。非常快速而且非常简单.-- Graeme HiltonR& D EngineerSchlumberger SensaDavid Watling在02上写了以下内容 / 11/2005 14:08:>嗨Graeme,>我写了一个byteswop公式,它可以在>一次的数组的所有元素上工作。 将数组加载为INT16,然后运行swopper功能。 您可能>或者可能不想要2的cmpl函数。>>函数byteswop int16:> bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)) ;>> 2的cmpl> asInt16(A-(A DIV 32768)* 65536); >>>问候>> David Watling >> -----原始信息----->来自:Graeme Hilton [mailto:GHilton @ slb.com]>发送时间:2005年11月2日13:43>收件人:VRF>主题:[vrf]字节数组转换为int16s数组>> Hi All,>>这是我最新的谜题; >>我正在阅读数据 来自TCP / IP套接字。 我读取32002个字节>> 16001 16位整数。 我不能使用READ BINARY x INT16 ARRAY1D> 16001,因为>数据首先显示为LSB,而To / From Socket对象假设>它> MSB优先。>>要将这些数字拼接在一起,我将执行以下操作:> For Each(A [2 * i] + A [(2 * i)+1] * 256)并收集结果以创建我的> int16> 16001元素数组。>>我的问题是这需要大量的 时间(与计划的其余部分相比)。 有没有人有非循环方式这样做或>另一个>节省时间的方法?> ---您目前订阅vrf为:r***@soco.agilent.com要订阅发送空白电子邮件到“join-vrf @ it.lists.it.agilent.com“。要取消订阅,请发送一封空白电子邮件至”leave-vrf@it.lists.it.agilent.com“。要发送邮件至此邮件列表,请发送电子邮件至”vrf@agilent.com“ 。 如果您需要有关邮件列表的帮助,请发送邮件至“owner-vrf@it.lists.it.agilent.com”。在“www.oswegosw.com/vrf_archive/”上搜索“非官方vrf档案”。 以上来自于谷歌翻译 以下为原文 Thanks Dave, I had to fiddle a little to get this to accept my data, but it works well. However, I persevered a little more with the socket reading and came up with this: From Socket, READ BINARY x BYTE ARRAY:16001,2 Then a formula: (x[*,1]*256+x[*,0]) to marry the two columns of bytes together. Very quick and very simple. -- Graeme Hilton R&D Engineer Schlumberger Sensa David Watling wrote the following on 02/11/2005 14:08: > Hi Graeme, > I wrote a byteswop formula which works on all elements of the array at > once. Load the array as INT16, then run the swopper function. You may > or may not want the 2's cmpl function as well. > > Function byteswop int16: > bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00)); > > 2's cmpl > asInt16(A-(A DIV 32768)*65536); > > > Regards > > David Watling > > -----Original Message----- > From: Graeme Hilton [mailto:GHilton@slb.com] > Sent: 02 November 2005 13:43 > To: VRF > Subject: [vrf] Array of bytes convert to array of int16s > > Hi All, > > Here's my latest puzzle; > > I am reading data from a TCP/IP socket. I read 32002 bytes which > represent > 16001 16-bit integers. I can't use the READ BINARY x INT16 ARRAY1D > 16001 as the > data is presented as LSB first whereas the To/From Socket object assumes > it's > MSB first. > > To stitch these numbers together I run through the following: > For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my > int16 > array of 16001 elements. > > My problem is that this takes a significant amount of time (compared to > the rest > of the program). Does anyone have a non-looping way of doing this or > another > time-saving method? > --- You are currently subscribed to vrf as: [email=r***@soco.agilent.com]r***@soco.agilent.com[/email] To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com". To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/". |
|
|
|
只有小组成员才能发言,加入小组>>
1223 浏览 0 评论
2347 浏览 1 评论
2157 浏览 1 评论
2022 浏览 5 评论
2902 浏览 3 评论
965浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
701浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
801浏览 0评论
1224浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 10:50 , Processed in 1.486680 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号