andybdjuk Posted October 31, 2010 Share Posted October 31, 2010 Hi, Simple one I feel now i have worked out the correct CRC, if i put :- \x06\x0A\x81\x00\x00\x00\xFF\xFF\x34\xCE in the comm monitor I receive my data:- Tx (20:29:45.762): \x06\x0A \x81\x00\x00\x00\xFF\xFF\x34\xCE Rx (20:29:45.800): \x81\x4B\x00\x06\x00\x00\x00\x40\x00\x00\x40\x00\x13\x02\x00\x01\x00\x00\x00\x00\x06\x05\x00\x02\x14\x00\x0C\x10\x1C\x01\x01\x01\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF\x00\xD2\x00\x00\x07\x15\x1C\x07\x07\x00\x15\x07\x1E\x11\x12\x00\x11\x15\x00\x11\x08\x00\x15\x0A \x00\x10\x18\x00\x10\x18\x00\x10\x34\xF7 But when i try a quick sequence in a button device.thermo.write(\x06\x0A\x81\x00\x00\x00\xFF\xFF\x34\xCE) I have no luck, could you remind me of the correct syntax, i have looked at the manual........but...........umm Thanks Andy Link to comment Share on other sites More sharing options...
AzeoTech Posted October 31, 2010 Share Posted October 31, 2010 Backslash notation is for the monitor only. If you have a string of binary values like this, its easiest to use chra(): device.thermo.write(chra({0x06, 0x0a, 0x81, 0x00, 0x00, 0x00, 0xff, 0xff, 0x34, 0xce})) Link to comment Share on other sites More sharing options...
andybdjuk Posted November 5, 2010 Author Share Posted November 5, 2010 Can you help me out with the next bit and that is to read the response that comes back as per the example in the OP. I only need to use the Nth byte of the string, put it in a channel so I can send the value to DaqConnect. I would like to do this every minute. Sorry that these are basic questions Andy Link to comment Share on other sites More sharing options...
AzeoTech Posted November 7, 2010 Share Posted November 7, 2010 I don't see a handy delimiter, so I'm guessing its fixed field: that the response is always a certain number of bytes. If so, do: private string datain = device.mydevice.read(x) where x is however many bytes you expect. You could also just do read(n) where n is the byte number you want, and then do purge() to clear out the rest (or do it right before the write()) Then do: private data = asca(datain) which is the opposite of chra() and will convert the response string into an array of numbers which you can easily extract the nth byte by using normal [] notation. Link to comment Share on other sites More sharing options...
andybdjuk Posted November 7, 2010 Author Share Posted November 7, 2010 That's fantastic. Thanks for your time and support, I had been reading the manual and experimenting but alas... One other thing, I have my test channel sending a value to DaqConnect but it is Value[0] that is being sent & I need to send Value[28] and maybe at a later date others to DaqConnect from that channel. So what i done was create a 2nd test channel and just addvalue(mychannel[28])and that works fine BUT is there a simpler way of doing it rather than having to set up another channel? Thanks Andy Link to comment Share on other sites More sharing options...
AzeoTech Posted November 10, 2010 Share Posted November 10, 2010 You can use the DAQConnect.addValue() function. I believe it takes two parameters, a string with the tag name, and the value. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.