Hello,
I developed an Hotel Room management system (VB>NET). Up to now I was using dllImports to integrate electronic key door system , but this time I would like to connect directly to encoder interface.
the encoder use a USB to UART driver ( I get the latest drivers from sil lab ) and it work good ( OS
is win 7) , Also this is my first time working on serialCom .
I build a test application to connect to the com port but I am not sure that I am even connecting to the encoder.
I use the Advanced serial Monitor port to comapre , what my test RS 232 code is sending (TX) and what my other test app ( using the manufacture dll through dllImport) is sending .
The dllImport test app is adding some charaters in the string who just dont make sens to me .
the doc coming with the encoder aspecify this data structure:
Data Format
Data format: 1 start bit, 1 end bit, 8 data bits, no verification; The communication rate is from 2400bps to 19200bps.
Control Character
STX (0x02): Tag the beginning of the data.
ETX (0x03): Tag the end of the data.
Information Format
Information format: <STX>ddssff[data]<ETX>cc
When the receiving end gets the information complying with the above format, it will respond with “ACK” if the calculated verification is same as the received verification. Otherwise, it will respond with “NAK”.
Information Field Description
dd Destination address, target (client) address
ss Source address which tags the information source
ff Command or answer code
[data] Data region (optional)
Check character: 2-byte;
Algorithm: Use 0x00 as the seed to do XOR with all the data after STX. The result of each XOR will be used as the new seed for the next XOR. The final 1-byte result will be transformed into a 2-byte hexadecimal ASCII code.
Example:
STX 0x30 0x39 0x52 ETX C1 C2
First calculation: 0x00 XOR 0x30 = 0x30
Second calculation: 0x30 XOR 0x39 = 0x09
Third calculation: 0x09 XOR 0x52 = 0x5B
Forth calculation: 0x5B XOR 0x03 = 0x58
Verification code of the first byte (C1): 0x5 ->ASCII 5 = 0x35
Verification code of the second byte (C2): 0x8 ->ASCII 8 = 0x38
and my test is : <STX>0103E<ETX>CC
//////
Card Verification/Guest Card Reading Command
Command code: (E).
This command is used to read the information in guest card and search the card’s information in the database. If the search is successful, relative information (R, N, D and O) will be fed back. Example as follows:
PMS: <STX>0103E<ETX>CC
AIS: <ACK>
AIS: <STX>03010<RS>R101<RS>NDuck<RS>D200212201200<RS>O200212302100<ETX>CC
PMS: <ACK>
/////////////
this is what the serial port monitore show:
<20110405141219.100 SYS>
COM port is opened
<20110405141219.100 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110405141219.100 SYS>
Baud rate 9600
<20110405141219.100 SYS>
RTS off
<20110405141219.100 SYS>
DTR off
<20110405141219.100 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110405141219.100 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110405141219.100 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=2048, XoffLimit=512
<20110405141219.100 SYS>
In/out queue size 512/512
<20110405141219.100 SYS>
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier=2000, ReadTotalTimeoutConstant=2000, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0
<20110405141219.100 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110405141219.100 TX>
<STX>103E<ETX>74
<20110405141231.163 SYS>
COM port is closed
and this is the dllimport test show , sending the same query:
IOCTL_SERIAL_SET_DTR: Set DTR
000031: I/O Request (UP), 29.03.2011 16:47:51.075 +0.0
IOCTL_SERIAL_SET_DTR: Set DTR
000032: I/O Request (DOWN), 29.03.2011 16:47:51.075 +0.0
IOCTL_SERIAL_SET_LINE_CONTROL: Set line control
WordLength=8
StopBits=1 stop bit
Parity=No parity
000033: I/O Request (UP), 29.03.2011 16:47:51.090 +0.015
IOCTL_SERIAL_SET_LINE_CONTROL: Set line control
000034: I/O Request (DOWN), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_CHARS: Set special characters
EofChar=0x0
ErrorChar=0x0
BreakChar=0x0
EventChar=0x0
XonChar=0x11
XoffChar=0x13
000035: I/O Request (UP), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_CHARS: Set special characters
000036: I/O Request (DOWN), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_HANDFLOW: Set handshake information
ControlHandShake=1
FlowReplace=0
XonLimit=28672
XoffLimit=7168
000037: I/O Request (UP), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_HANDFLOW: Set handshake information
000040: I/O Request (DOWN), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_TIMEOUTS: Set timeouts
ReadIntervalTimeout=4294967295 >>> when I try to put this value I get an error in my 232 class
ReadTotalTimeoutMultiplier=0
ReadTotalTimeoutConstant=0
WriteTotalTimeoutMultiplier=0
WriteTotalTimeoutConstant=5000
000041: I/O Request (UP), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_SET_TIMEOUTS: Set timeouts
000042: I/O Request (DOWN), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_PURGE: Purge requests
Purge mask=TXABORT: Read requests, RXABORT: Receive buffer, TXCLEAR: Write requests, RXCLEAR: Write buffer
000043: I/O Request (UP), 29.03.2011 16:47:51.090 +0.0
IOCTL_SERIAL_PURGE: Purge requests
000044: Write Request (DOWN), 29.03.2011 16:47:51.090 +0.0
Buffer size: 0x16 bytes
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 7E ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~
FF 00 DF 0B 17 7E ÿ.ß..~
000049: Read Request (UP), 29.03.2011 16:47:51.121 +0.0
Buffer size: 0x1 bytes
Status: 0x00000000
7E ~
000053: Read Request (UP), 29.03.2011 16:47:51.121 +0.0
Buffer size: 0x1 bytes
Status: 0x00000000
00 .
000057: Read Request (UP), 29.03.2011 16:47:51.121 +0.0
Buffer size: 0x1 bytes
Status: 0x00000000
00 .
etc.....
There is many additional characteres who dont make sens to me the why all the ""FF"" and also the translation show 7E ÿ.ß..~... what does that mean ...? when my rs232 code show this as hex value:
WriteTotalTimeoutConstant=100 103E74COM port is close
when compare with a serial monitor
( using dllimport and the encodoer dll)
00000129 24.03.2011 19:52:25.419 +0.0 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_SET_TIMEOUTS UP 0x00000000
00000130 24.03.2011 19:52:25.419 +0.0 IRP_MJ_WRITE DOWN 0x00000000 7e ff 03 80 31 85 02 00 63 5b e0 7e ~...1...c[.~
(using my ES232 test app)
00000049 24.03.2011 20:20:36.259 +0.006 IRP_MJ_DEVICECONTROL: IOCTL_SERIAL_PURGE UP 0x00000000
00000050 24.03.2011 20:20:48.354 +12.094 IRP_MJ_WRITE DOWN 0x00000000 3c 45 54 58 3e 31 3c 45 4e 51 3e 3c 4e 55 4c 3e <ETX>1<ENQ><NUL>
with the mfct dll the bytes translate to those funny characters ""~...1...c[.~"" when I run the same command in my test app the bytes show in char that we can read ""<ETX>1<ENQ><NUL>"" so am I doing something wrong in the convert function
this is my first posting on this board so I hope that I didn't exceed the lenght and I will be happy to attached any piece of code or doc that I have and who are needed to resolve this .
Sincerely,
alan