sadyrbek Posted July 18, 2008 Share Posted July 18, 2008 hi, what is the problem in this code: private string crc=({0x3D98}) device.mydevice.write(chra({1,0xFA,0x00,0x00,0x00,0x00,0x00,0x00,0x75,0x30,0x00, x3E}),crc) thank you. Link to comment Share on other sites More sharing options...
AzeoTech Posted July 18, 2008 Share Posted July 18, 2008 Several things: private string crc=({0x3D98}) 1) You are assigning a number to a string. 2) You could use doubletostr(), but I think you really want to use chra(To.urWord(0x3D98)) because you want to break the word 0x3d98 into its two bytes, 0x3d and 0x98. Alternatively, you could do: chra({0x3d,0x98}). 3) You don't need the {} when you have a scalar value and not an array. You also don't need the parenthesis. They don't hurt, but it makes it a little harder to read. device.mydevice.write(chra({1,0xFA,0x00,0x00,0x00,0x00,0x00,0x00,0x75,0x30,0x00, 3E}),crc) Here you are specifying two parameters to the write() function when it only accepts one. This is because you put the ,crc at the end. Since chra() and crc are both strings, what you really want is a + to concatenate them. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.