title: How to format the command in order to write on serial port
body: <p>I have a card/rfid reader and I am trying to create a test application for it. I do have a protocol description document from the provider but I have never wrote serial port software before and everything looks so strange to me. I do have programming skils but a just do not know what I am doing wrong.</p>
  
  <p>So, the model of the device is CRT288. In the spec doc I have the following data:</p>
  
  <p>Baud rate (BPS): 9600</p>
  
  <p>Communication type: Asynchronous communication</p>
  
  <p>Transmit type: Half duplex </p>
  
  <p>Bit detail: Start bit: 1 bit </p>
  
  <p>Data bit: 8 bit </p>
  
  <p>Parity bit: None </p>
  
  <p>Stop bit: 1 bit </p>
  
  <p>Start bit D0 D1 D2 D3 D4 D5 D6 D7 Stop sbit</p>
  
  <p>Transmission Control Codes:</p>
  
  <p>Code Value Meaning </p>
  
  <p>STX 0x02 Start character of data package </p>
  
  <p>ETX 0x03 End character of data package </p>
  
  <p>ENQ 0x05 Sending require command (host -> reader) </p>
  
  <p>ACK 0x06 Positive answer(reader-host)</p>
  
  <p>NAK 0x15 Negative answer(reader-host) </p>
  
  <p>EOT 0x04 Cancel communication </p>
  
  <p>And most important (I believe) the data package  format of command:</p>
  
  <p>STX(0x02) Command package ETX (0x03) BCC</p>
  
  <p>BCC(Block check character) = STX ^ Command Package ^ ETX </p>
  
  <p>(^ is exclusive OR calculation character)</p>
  
  <p>For example: Reset command:</p>
  
  <p>BCC=0x02 ^ 0x00 ^ 0x02 ^ 0x30 ^ 0x30 ^ 0x03 </p>
  
  <p>meaning (STX ^ MSL ^ CMD ^ CMP ^ SDT ^ ETX)</p>
  
  <p>(1) MSL Length of sending text</p>
  
  <p>(2)CMD Specifies a command.</p>
  
  <p>(3)CMP Command Parameter.</p>
  
  <p>(4)SDT Specifies the sending data, and has variable length(0~264bytes). </p>
  
  <p>I have installed some doftware called Serial Port Monitor 4.0 (Eltima) and I am trying to send a command but it does not seem to work.</p>
  
  <p>0x02 ^ 0x00 ^ 0x02 ^ 0x30 ^ 0x30 ^ 0x03 seems to be 11 or something.</p>
  
  <p>Does anybody have a clue how to send a proper command using this specifications ?</p>
  
  <p>On top of that, the reader ate one card, and I can not even reject teh card.
  It is expcetcing a command for that :)</p>
  
  <p>So if you guys have a simpel code sample in java or c# or how to properly format a command and send it to the rs232 please help me.</p>
  
  <p>A</p>