2
good afternoon!
I need a help that would be another explanation in a certain way.
I am doing homologation of an equipment that send data via rs232 however the equipment does not have a protocol that can assist informing the order of the data and etc only an Appendix of Host slave. I just wanted to understand the rs232 data processing process in C#. come on:
this is the data I receive in my gateway:
33463031313033443031313130313131
35423638333035443542363733303544
53696E676C6520576569676874303332
35303F3F3F3F2E546F74616C20576569
6768743A303030333235306B672E3031
31303031313030313130303131303031
3130
In ASCII
is as follows: 3F01103D011101115B68305D5B67305DSingle Weight03250????.Total Weight:0003250kg.01100110011001100110
However, in Appendix it says that the data is of type Long, Attribute R, and the command is HEX 03. I don’t know if I could be clear if my source where I work the data:
var rs232 = aAux[it++];
int desloc = 0;
int _base = 0;
var balanca = ASCIItoHex(rs232);
byte[] fadiga = BitHandler.GetBytes(rs232, BytesFormatInput.ASCII);
var weight = new WeightPro();
weight.Ativo = (ulong)fadiga[desloc + _base + 1] << 00;
weight.Ativo |= (ulong)fadiga[desloc + _base + 2]<< 08;
weight.Ativo |= (ulong)fadiga[desloc + _base + 3]<< 16;
weight.Position = fadiga[desloc + _base + 2];
weight.DateTime = fadiga[desloc + _base + 3];
weight.Usuario = fadiga[desloc + _base + 4];
weight.Produto = fadiga[desloc + _base + 5];
weight.Placa = fadiga[desloc + _base + 6];
weight.TotalWeight = fadiga[desloc + _base + 7];
weight.Weight = fadiga[desloc + _base + 8];
weight.Record = fadiga[desloc + _base + 9];
Base.System.SystemEventManager.Instance.WriteLine(weight.ToString());
Screen result:
Properties Weight Pro
Ativo:3158320
Position:49
DateTime:48
Usuario:51
Produto:49
Placa:48
TotalWeight:48
Weight:48
Record:48
Good people, if anyone can help me. These data I mentioned above are the protocol Modbus ASCII, I researched a lot about this protocol but I still do not understand how to read it. If you can shed some light, I’d be grateful.
– Gustavo .NET