B4R Question It is recommended to add some new data conversion methods in B4R

santook

Member
Limited to my ability to master English, the following comes from the translation tool。
Although the existing ULongsFromBytes data type conversion methods, but for protocol analysis is not very convenient. Is it possible that these methods are consistent with the ToUInt32 provided by the ByteConversion class of VB.NET?

B4X:
ByteConverter.ToINT(data() as byte,byte start)as INT
ByteConverter.ToUINT(data() as byte,byte start)as UINT
ByteConverter.ToLONG(data() as byte,byte start)as LONG
ByteConverter.ToULONG(data() as byte,byte start)as ULONG
ByteConverter.ToFLOAT(data() as byte,byte start)as FLOAT
ByteConverter.ToDOUBLE(data() as byte,byte start)as DOUBLE

ByteConverter.FromINT(data as int) as byte()
ByteConverter.FromUINT(data as uint) as byte()
ByteConverter.FromLONG(data as long) as byte()
ByteConverter.FromULONG(data as ulong) as byte()
ByteConverter.FromFLOAT(data as float) as byte()
ByteConverter.FromDOUBLE(data as double) as byte()
 

santook

Member
I think it should not affect the performance of the MCU, because the pointer operation will soon
B4X:
int ToINT(unsigned char *data,unsigned char start)
{
   int ret=0;
   ret=*(data+start);
   return ret;
}
 
Upvote 0

santook

Member
buf()=> 0xFF 0xFA,0x01,0x22 0x01 0x01 0xDE,0x11 0xF,0x0D 0x0A
HEAD,ID,float value 1,int value2,End of Frame
B4X:
Log("Float Value:",bc.ToFloat(buf,3))
Log("Int Value:",bc.ToInt(buf,7))
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is it possible that these methods are consistent with the ToUInt32 provided by the ByteConversion class of VB.NET
B4R ByteConverter is consistent with the ByteConverter library available in other B4X tools. Note that RandomAccessFile methods are more similar to the methods you posted.
 
Upvote 0

santook

Member
Erel, thank you very much for your help. Problem has been solved.Create a new RandomAccessFile Object Will it take up more memory resources?
 
Upvote 0
Top