Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending Byte List
#6
(08-29-2018, 11:43 AM)CaptRick Wrote: I sent the bytes like this but I don't think it's right?:

IdTCPClient.IOHandler.Write(@TxBuffer[0],7);

No, it is not. Use this instead, which sends the entire array as-is:

Code:
IdTCPClient.IOHandler.Write(TxBuffer);

Or, you can use this, which lets you specify how many bytes to send (ie, if you had a larger array that you wanted to send a smaller portion of):

Code:
IdTCPClient.IOHandler.Write(TxBuffer, 7);

(08-29-2018, 11:43 AM)CaptRick Wrote: I need to receive a byte array. The protocol is a lightweight datalink protocol, framed by simple headers (Start of Frame byte, inverted payload length, payload length, (Payload is a packed record structure of bytes and words, then an array of words) followed by two bytes of the 'Modbus' CRC, which I am calculating fine.

Good. Then you can simply read the header first, then read however many bytes the header says are in the payload. The IOHandler has many methods that would be suitable for this task - ReadByte(), ReadBytes(), ReadInt16/32/64(), etc (and conversely, equivalents for sending data).

Reply


Messages In This Thread
Sending Byte List - by krshin - 08-22-2018, 07:19 PM
RE: Sending Byte List - by rlebeau - 08-22-2018, 08:27 PM
RE: Sending Byte List - by krshin - 08-23-2018, 05:52 AM
RE: Sending Byte List - by rlebeau - 08-23-2018, 10:32 PM
RE: Sending Byte List - by CaptRick - 08-29-2018, 11:43 AM
RE: Sending Byte List - by rlebeau - 08-29-2018, 06:22 PM
RE: Sending Byte List - by CaptRick - 08-29-2018, 10:50 PM
RE: Sending Byte List - by CaptRick - 08-31-2018, 10:38 AM
RE: Sending Byte List - by rlebeau - 08-31-2018, 05:10 PM
RE: Sending Byte List - by CaptRick - 08-31-2018, 09:02 PM
RE: Sending Byte List - by rlebeau - 08-31-2018, 09:35 PM
RE: Sending Byte List - by CaptRick - 08-31-2018, 09:46 PM
RE: Sending Byte List - by CaptRick - 09-01-2018, 12:46 PM
RE: Sending Byte List - by CaptRick - 09-04-2018, 03:35 PM
RE: Sending Byte List - by rlebeau - 09-04-2018, 06:32 PM
RE: Sending Byte List - by kudzu - 09-05-2018, 02:28 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)