2

I am writing an interface to a clinical lab machine, which uses ASTM protocol for communication (http://makecircuits.com/blog/2010-06-25-astm-protocol.html).

To start with, I am trying to use golang's TCP Server to receive data. But not able to figure how to send ACK back to lab machine. I am a newbie in golang. Can any one suggest how I can proceed?

Vijendra
  • 338
  • 3
  • 11
  • 1
    Are you certain `ENQ` and `ACK` in this context refer to types of TCP packets? (there don't seem to be any open specifications for ASTM E-1394). That summary makes it look as if it's a text protocol over tcp, and you simply write those ascii codes on the line, but there's no description of what the physical or transport layer are supposed to be. – JimB Feb 05 '16 at 14:00
  • 2
    Actually, looking at the example order on that page, the codes like ``, ``, ``, ``, etc. are all ASCII characters. Do you just need to know how to write those to a network connection? – JimB Feb 05 '16 at 14:06
  • Thank you. That should be write. Yet to check it with actual machine integration. But I found a ruby test code client.putc(0x06.chr), we have written long back, which shows it is just ASCII chars. – Vijendra Feb 07 '16 at 12:31
  • OK, so do you still have a question? If so please edit this with an example showing where you're having a problem. – JimB Feb 08 '16 at 15:01
  • Sorry for the delayed response. Sending HEX ACK like this works fine. c := &serial.Config{Name: "/dev/ttyUSB0", Baud: 9600, Size: 8} conn, err := serial.OpenPort(c) conn.Write([]byte{0x06}) – Vijendra Oct 19 '16 at 08:52

1 Answers1

0

The protocol in the link you supplied is for RS232. When sending data over TCPIP it is a stream (the receiver has to know when the data ends). Normally when changing an RS232 protocol to TCPIP, a header is added to each message which is the length of the message (often two bytes), so if you want to send ASCII ACK you send three bytes a two byte length and one byte data. When writing this you must flush the buffer, as for such a small packet it will not be transmitted until you do.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
user3782299
  • 333
  • 3
  • 9