hiramlight
asked on
RF card encoder with RS232 nterface network system
Hello ,
This new to me, 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) .
I build a test application to connect to the com port and also , it seem to open the port with no problem .
what I don’t get is how to correctly format the string og command that I send to the decoder so I get a response from it .
I have Advances Serial port Analyzer so I will attached 2 files one who show a correct call from my test app (using dllImport), and the other one using my other test app talking directly to encoder interface. .
ok, to connect to the com port I use this :
-------------------------
Private Sub btnOpenCom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenCom.Click
moRS232 = New Rs232()
Try
'// Setup parameters
With moRS232
.Port = miComPort
.BaudRate = Int32.Parse(txtBaudrate.Te xt)
.DataBit = 8
.StopBit = Rs232.DataStopBit.StopBit_ 1
.Parity = Rs232.DataParity.Parity_No ne
.Timeout = Int32.Parse(txtTimeout.Tex t)
End With
'// Initializes port
moRS232.Open()
'// Set state of RTS / DTS
moRS232.Dtr = (chkDTR.CheckState = CheckState.Checked)
moRS232.Rts = (chkRTS.CheckState = CheckState.Checked)
If chkEvents.Checked Then moRS232.EnableEvents()
chkEvents.Enabled = True
Catch Ex As Exception
MessageBox.Show(Ex.Message , "Connection Error", MessageBoxButtons.OK)
Finally
btnCloseCom.Enabled = moRS232.IsOpen
btnOpenCom.Enabled = Not moRS232.IsOpen
btnTx.Enabled = moRS232.IsOpen
btnRx.Enabled = moRS232.IsOpen
btnCheck.Enabled = moRS232.IsOpen
End Try
End Sub
-------------------------- ---------- ---------- -
To send a command to the serial interface I use this:
-------------------------- --
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTx.Click
Dim sTx As String
'----------------------
'// Clear Tx/Rx Buffers
moRS232.PurgeBuffer(Rs232. PurgeBuffe rs.TxClear Or Rs232.PurgeBuffers.RXClear )
sTx = txtTx.Text
If chkAddCR.Checked Then sTx += ControlChars.Cr
moRS232.Write(sTx)
'moRS232.Write(Chr(2) & Chr(2) & Chr(73) & Chr(48) & Chr(121) & Chr(3))
'// Clears Rx textbox
txtRx.Text = String.Empty
txtRx.Refresh()
lbHex.Items.Clear()
If chkAutorx.Checked Then Button1_Click(Nothing, Nothing)
End Sub
-------------------------- ---------- --
and that is what my serial com reader return when using my test app to directly connect to encoder interface ( I send a simple <ENQ> command TX according to the chart:
5 5 005 ENQ (enquiry) 37 25 045 % 69 45 105 E 101 65 145 e
so I should get something back from the encoder interface in the form of RX but nothing
========================== ====
<20110314211032.755 SYS>
COM port is opened
<20110314211032.755 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110314211032.755 SYS>
Baud rate 9600
<20110314211032.770 SYS>
RTS off
<20110314211032.770 SYS>
DTR off
<20110314211032.786 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110314211032.786 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110314211032.786 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=32768, XoffLimit=8192
<20110314211032.786 SYS>
In/out queue size 512/512
<20110314211032.786 SYS>
Set timeouts: ReadInterval=0, ReadTotalTimeoutMultiplier =0, ReadTotalTimeoutConstant=1 500, WriteTotalTimeoutMultiplie r=10, WriteTotalTimeoutConstant= 100
<20110314211032.786 SYS>
DTR off
<20110314211032.801 SYS>
RTS off
<20110314211039.166 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110314211039.166 TX>
<ENQ>
<20110314211043.019 SYS>
COM port is closed
========================== =======
Now below is a correct sequence checking the card number.
( I use DllImport with the dll provided by the encoder manufacturer)
========================== ========== =
<20110314211118.067 SYS>
COM port is opened
<20110314211118.067 SYS>
Baud rate 9600
<20110314211118.067 SYS>
RTS off
<20110314211118.083 SYS>
DTR off
<20110314211118.083 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110314211118.099 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110314211118.099 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=32768, XoffLimit=8192
<20110314211118.099 SYS>
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier =2000, ReadTotalTimeoutConstant=2 000, WriteTotalTimeoutMultiplie r=0, WriteTotalTimeoutConstant= 0
<20110314211118.099 TX>
~ÿ<ETX>€1<ENQ><NUL>g2~
<20110314211118.223 RX>
~ÿ<ETX>€1<NUL><DC4><CAN><N AK><NUL><N UL>Y<NUL>< NUL>,ÞÇ€<N UL><NUL><N UL><NUL>ªª ª<NUL><NUL >ÍÂ~
<20110314211118.270 SYS>
COM port is closed
===============
<20110314211118.099 TX>
~ÿ<ETX>€1<ENQ><NUL>g2~
<20110314211118.223 RX>
~ÿ<ETX>€1<NUL><DC4><CAN><N AK><NUL><N UL>Y<NUL>< NUL>,ÞÇ€<N UL><NUL><N UL><NUL>ªª ª<NUL><NUL >ÍÂ~
herewe can see the transmit and received TX - RX and that in the previos test I format do not format my command string correctly.
I try by entering ~ÿ<ETX>€1<ENQ><NUL>g2~ and all it does is is show
<20110314211039.166TX>
~ÿ<ETX>€1<ENQ><NUL>g2
in the comserial reader .. but no response from the encoder serial interface.
I notice also , that my tets app setup is :
Set timeouts: ReadInterval=0, ReadTotalTimeoutMultiplier =0, ReadTotalTimeoutConstant=1 500, WriteTotalTimeoutMultiplie r=10, WriteTotalTimeoutConstant= 100
when the test app with dllimports shoe;
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier =2000, ReadTotalTimeoutConstant=2 000, WriteTotalTimeoutMultiplie r=0, WriteTotalTimeoutConstant= 0
can that have an effect an ne were to setup those
As I said this new to me , I can find HEX value of ~ÿ like the translation show : 7E FF outConstant=0 ~ÿ
0x190 03 80 31 05 00 67 32 7E 7E FF 03 80 31 00 14 18 .€1..g2~~ÿ.€1...
0x1A0 15 00 00 59 00 00 2C CC C7 80 00 00 00 00 AA AA ...Y..,ÌÇ€....ªª
0x1B0 AA 00 00 DA A1 7E
there is definatly something that I missed or do not understand .... a liitle bit of help and guidance would be greatly appreciated.
will post any log or code needed in order to resolve this
Thank's
alan
This new to me, 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) .
I build a test application to connect to the com port and also , it seem to open the port with no problem .
what I don’t get is how to correctly format the string og command that I send to the decoder so I get a response from it .
I have Advances Serial port Analyzer so I will attached 2 files one who show a correct call from my test app (using dllImport), and the other one using my other test app talking directly to encoder interface. .
ok, to connect to the com port I use this :
-------------------------
Private Sub btnOpenCom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenCom.Click
moRS232 = New Rs232()
Try
'// Setup parameters
With moRS232
.Port = miComPort
.BaudRate = Int32.Parse(txtBaudrate.Te
.DataBit = 8
.StopBit = Rs232.DataStopBit.StopBit_
.Parity = Rs232.DataParity.Parity_No
.Timeout = Int32.Parse(txtTimeout.Tex
End With
'// Initializes port
moRS232.Open()
'// Set state of RTS / DTS
moRS232.Dtr = (chkDTR.CheckState = CheckState.Checked)
moRS232.Rts = (chkRTS.CheckState = CheckState.Checked)
If chkEvents.Checked Then moRS232.EnableEvents()
chkEvents.Enabled = True
Catch Ex As Exception
MessageBox.Show(Ex.Message
Finally
btnCloseCom.Enabled = moRS232.IsOpen
btnOpenCom.Enabled = Not moRS232.IsOpen
btnTx.Enabled = moRS232.IsOpen
btnRx.Enabled = moRS232.IsOpen
btnCheck.Enabled = moRS232.IsOpen
End Try
End Sub
--------------------------
To send a command to the serial interface I use this:
--------------------------
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTx.Click
Dim sTx As String
'----------------------
'// Clear Tx/Rx Buffers
moRS232.PurgeBuffer(Rs232.
sTx = txtTx.Text
If chkAddCR.Checked Then sTx += ControlChars.Cr
moRS232.Write(sTx)
'moRS232.Write(Chr(2) & Chr(2) & Chr(73) & Chr(48) & Chr(121) & Chr(3))
'// Clears Rx textbox
txtRx.Text = String.Empty
txtRx.Refresh()
lbHex.Items.Clear()
If chkAutorx.Checked Then Button1_Click(Nothing, Nothing)
End Sub
--------------------------
and that is what my serial com reader return when using my test app to directly connect to encoder interface ( I send a simple <ENQ> command TX according to the chart:
5 5 005 ENQ (enquiry) 37 25 045 % 69 45 105 E 101 65 145 e
so I should get something back from the encoder interface in the form of RX but nothing
==========================
<20110314211032.755 SYS>
COM port is opened
<20110314211032.755 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110314211032.755 SYS>
Baud rate 9600
<20110314211032.770 SYS>
RTS off
<20110314211032.770 SYS>
DTR off
<20110314211032.786 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110314211032.786 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110314211032.786 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=32768, XoffLimit=8192
<20110314211032.786 SYS>
In/out queue size 512/512
<20110314211032.786 SYS>
Set timeouts: ReadInterval=0, ReadTotalTimeoutMultiplier
<20110314211032.786 SYS>
DTR off
<20110314211032.801 SYS>
RTS off
<20110314211039.166 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110314211039.166 TX>
<ENQ>
<20110314211043.019 SYS>
COM port is closed
==========================
Now below is a correct sequence checking the card number.
( I use DllImport with the dll provided by the encoder manufacturer)
==========================
<20110314211118.067 SYS>
COM port is opened
<20110314211118.067 SYS>
Baud rate 9600
<20110314211118.067 SYS>
RTS off
<20110314211118.083 SYS>
DTR off
<20110314211118.083 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110314211118.099 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20110314211118.099 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=32768, XoffLimit=8192
<20110314211118.099 SYS>
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier
<20110314211118.099 TX>
~ÿ<ETX>€1<ENQ><NUL>g2~
<20110314211118.223 RX>
~ÿ<ETX>€1<NUL><DC4><CAN><N
<20110314211118.270 SYS>
COM port is closed
===============
<20110314211118.099 TX>
~ÿ<ETX>€1<ENQ><NUL>g2~
<20110314211118.223 RX>
~ÿ<ETX>€1<NUL><DC4><CAN><N
herewe can see the transmit and received TX - RX and that in the previos test I format do not format my command string correctly.
I try by entering ~ÿ<ETX>€1<ENQ><NUL>g2~ and all it does is is show
<20110314211039.166TX>
~ÿ<ETX>€1<ENQ><NUL>g2
in the comserial reader .. but no response from the encoder serial interface.
I notice also , that my tets app setup is :
Set timeouts: ReadInterval=0, ReadTotalTimeoutMultiplier
when the test app with dllimports shoe;
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier
can that have an effect an ne were to setup those
As I said this new to me , I can find HEX value of ~ÿ like the translation show : 7E FF outConstant=0 ~ÿ
0x190 03 80 31 05 00 67 32 7E 7E FF 03 80 31 00 14 18 .€1..g2~~ÿ.€1...
0x1A0 15 00 00 59 00 00 2C CC C7 80 00 00 00 00 AA AA ...Y..,ÌÇ€....ªª
0x1B0 AA 00 00 DA A1 7E
there is definatly something that I missed or do not understand .... a liitle bit of help and guidance would be greatly appreciated.
will post any log or code needed in order to resolve this
Thank's
alan
ASKER
Hello Melmers,
I use a nifty app writen by Corrado Cavalli , to test the RS232 connection ...you can find it at :
http://www.codeworks.it/net/VBNetRs232.htm
Also I add the only doc i got from the encoder manufacturer on how to connect to the encoder ...
now ...
this the sub to send the string:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTx.Click
Dim sTx As String
'----------------------
'// Clear Tx/Rx Buffers
moRS232.PurgeBuffer(Rs232. PurgeBuffe rs.TxClear Or Rs232.PurgeBuffers.RXClear )
sTx = txtTx.Text
If chkAddCR.Checked Then sTx += ControlChars.Cr
moRS232.Write(sTx)
'// Clears Rx textbox
txtRx.Text = String.Empty
txtRx.Refresh()
lbHex.Items.Clear()
If chkAutorx.Checked Then Button1_Click(Nothing, Nothing)
End Sub
-----------------
then moRS232.Write(sTx):
Public Overloads Sub Write(ByVal Buffer As String)
'========================= ========== ========== ======
'
' Description : Writes a string to RS232
' Created : 04/02/2009 - 8:46:42
'
' *Parameters Info*
'
' Notes: 24/05/2009 Fixed problem with ASCII Encoding
'========================= ========== ========== ======
Dim oEncoder As New System.Text.ASCIIEncoding
Dim oEnc As Encoding = Encoding.GetEncoding(1252)
'------------------------- ---------- ---------- ---------- ------
Dim aByte() As Byte = oEnc.GetBytes(Buffer)
Me.Write(aByte)
End Sub
========================== ==========
I am pretty sure that you are right my the probllem is with encoding, could you give a short code example on how you would convert an UTF-16 encoding to a byte array
the command to send is pretty simple ( The 1 is to let the system knew this not a new card )
<ETX>1<ENQ><NUL
thank's
Alan
Adem-Interface-Network-Specifica.doc
I use a nifty app writen by Corrado Cavalli , to test the RS232 connection ...you can find it at :
http://www.codeworks.it/net/VBNetRs232.htm
Also I add the only doc i got from the encoder manufacturer on how to connect to the encoder ...
now ...
this the sub to send the string:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTx.Click
Dim sTx As String
'----------------------
'// Clear Tx/Rx Buffers
moRS232.PurgeBuffer(Rs232.
sTx = txtTx.Text
If chkAddCR.Checked Then sTx += ControlChars.Cr
moRS232.Write(sTx)
'// Clears Rx textbox
txtRx.Text = String.Empty
txtRx.Refresh()
lbHex.Items.Clear()
If chkAutorx.Checked Then Button1_Click(Nothing, Nothing)
End Sub
-----------------
then moRS232.Write(sTx):
Public Overloads Sub Write(ByVal Buffer As String)
'=========================
'
' Description : Writes a string to RS232
' Created : 04/02/2009 - 8:46:42
'
' *Parameters Info*
'
' Notes: 24/05/2009 Fixed problem with ASCII Encoding
'=========================
Dim oEncoder As New System.Text.ASCIIEncoding
Dim oEnc As Encoding = Encoding.GetEncoding(1252)
'-------------------------
Dim aByte() As Byte = oEnc.GetBytes(Buffer)
Me.Write(aByte)
End Sub
==========================
I am pretty sure that you are right my the probllem is with encoding, could you give a short code example on how you would convert an UTF-16 encoding to a byte array
the command to send is pretty simple ( The 1 is to let the system knew this not a new card )
<ETX>1<ENQ><NUL
thank's
Alan
Adem-Interface-Network-Specifica.doc
Hi Alan,
can you try to replace the code of the Write Sub
with this code:
can you try to replace the code of the Write Sub
with this code:
Dim ascEncoder As New System.Text.ASCIIEncoding
Dim ascBuffer() As Byte = ascEncoder.GetBytes(Buffer)
Me.Write(ascBuffer)
ASKER
Hi Melmers,
I made the change that you suggested but same result ( No reply, so I dont think I connect to the encoderin a way that it can recgnize)
so what I did is to chnage the serial port monitor setting to try to get a different reading . I set HEX #XX Code for all char set .
and that what I got >
<20110323175053.875 TX>
#7E#FF<ETX>#80#31<ENQ><NUL >#67#32#7E
<20110323175054.007 RX>
#7E#FF<ETX>#80#31<NUL><DC4 ><CAN><NAK ><NUL><NUL >#59<NUL>< NUL>#2C#EF <CAN>#8E<N UL><NUL><N UL><NUL>#A A#AA#AA<NU L><NUL>#C5 <DC3>#7E
<20110323175054.045 SYS>
COM port is closed
so actually .
~ÿ<ETX>€1<ENQ><NUL>g2 = #7E#FF<ETX>#80#31<ENQ><NUL >#67#32#7E
and if I send this (#7E#FF<ETX>#80#31<ENQ><NU L>#67#32#7 E) using my test app ( with the chnages that you suggested) that what happen all got convert to bytes like:
<20110323175551.522 TX>
#23#37#45#23#46#46#3C#45#5 4#58#3E#23 #38#30#23# 33#31#3C#4 5#4E#51#3E #3C#4E#55# 4C#3E#23#3 6#37#23#33 #32#23#37# 45
so maybe to convert sthe string to byte is not the correct format to tak to this kind of encoder. check this link,
(http://www.alibaba.com/trade/search?IndexArea=product_en&ssk=y&fsb=y&Type=BUY&SearchText=mifare+encoder)
the Mifare MCR-12 is the encoder I am using in this testing :
http://www.alibaba.com/product-gs/227794437/Card_encoder_EM_Mifare_magnetic_.html
thnak's
Alan
I made the change that you suggested but same result ( No reply, so I dont think I connect to the encoderin a way that it can recgnize)
so what I did is to chnage the serial port monitor setting to try to get a different reading . I set HEX #XX Code for all char set .
and that what I got >
<20110323175053.875 TX>
#7E#FF<ETX>#80#31<ENQ><NUL
<20110323175054.007 RX>
#7E#FF<ETX>#80#31<NUL><DC4
<20110323175054.045 SYS>
COM port is closed
so actually .
~ÿ<ETX>€1<ENQ><NUL>g2 = #7E#FF<ETX>#80#31<ENQ><NUL
and if I send this (#7E#FF<ETX>#80#31<ENQ><NU
<20110323175551.522 TX>
#23#37#45#23#46#46#3C#45#5
so maybe to convert sthe string to byte is not the correct format to tak to this kind of encoder. check this link,
(http://www.alibaba.com/trade/search?IndexArea=product_en&ssk=y&fsb=y&Type=BUY&SearchText=mifare+encoder)
the Mifare MCR-12 is the encoder I am using in this testing :
http://www.alibaba.com/product-gs/227794437/Card_encoder_EM_Mifare_magnetic_.html
thnak's
Alan
ASKER
Hi Melmers,
I add my rs232 class and form so you can have a bteer idea on whereI am at
Alan
rs232.vb
Default.aspx.vb
Default.aspx
I add my rs232 class and form so you can have a bteer idea on whereI am at
Alan
rs232.vb
Default.aspx.vb
Default.aspx
Hi, so after have a look at the documentation the tags <ETX> and <ENQ> etc. are placeholder.
STX (0x02): Tag the beginning of the data.
ETX (0x03): Tag the end of the data.
ENQ (0x05): Test the connection.
ACK (0x06): Response to the end which transmits the data and show that the transmitted data is correct.
NAK (0x15): Response to the end which transmits the data and show that the transmitted data is wrong.
RS (0x1E): Tag the beginning of the new field (region) and is followed by the field identification code.
please try to make that the strings STX, ETX etc. are convertet to their byte values.
STX (0x02): Tag the beginning of the data.
ETX (0x03): Tag the end of the data.
ENQ (0x05): Test the connection.
ACK (0x06): Response to the end which transmits the data and show that the transmitted data is correct.
NAK (0x15): Response to the end which transmits the data and show that the transmitted data is wrong.
RS (0x1E): Tag the beginning of the new field (region) and is followed by the field identification code.
please try to make that the strings STX, ETX etc. are convertet to their byte values.
ASKER
Hi Melmers,
I run more test today using Serial Monitor pro, so I could compare, a string sent to the encoder using untrf.dll who is formated correctly and the one using my test app....and I dont know enought about com transmition to be sure but it seem that the way I sent my data is wrong ...and by thta I meant it seem that each byte is send seperatly ....
with IRP_MJ_WRITE "DOWN" AND IRP_MJ_READ "UP" , the working call as 9 IRP_MJ_READ call and my test not 1 .. so definetly something I am doing wroong in RS232 class.
I attached the 3 files
I both format key session - paket viw I compare the between the correct working transmition to the encoder and the failed one from my test app . Unfoortunatly I dont know enought about this to really understand what I amdoing wrong , I thought before it was because of the format , I think now it is because I am not using the correct method
Format key session , I a complete and fully detail reccords of a sample call to the encoder to get a card number ( GetCardNumber) from the hunref.dll and correctly formated...
thank's for helping me on this , ...
Alan
format-key-session---paket-view.docx
format-key-session---paket-view-.docx
format-key-session.docx
I run more test today using Serial Monitor pro, so I could compare, a string sent to the encoder using untrf.dll who is formated correctly and the one using my test app....and I dont know enought about com transmition to be sure but it seem that the way I sent my data is wrong ...and by thta I meant it seem that each byte is send seperatly ....
with IRP_MJ_WRITE "DOWN" AND IRP_MJ_READ "UP" , the working call as 9 IRP_MJ_READ call and my test not 1 .. so definetly something I am doing wroong in RS232 class.
I attached the 3 files
I both format key session - paket viw I compare the between the correct working transmition to the encoder and the failed one from my test app . Unfoortunatly I dont know enought about this to really understand what I amdoing wrong , I thought before it was because of the format , I think now it is because I am not using the correct method
Format key session , I a complete and fully detail reccords of a sample call to the encoder to get a card number ( GetCardNumber) from the hunref.dll and correctly formated...
thank's for helping me on this , ...
Alan
format-key-session---paket-view.docx
format-key-session---paket-view-.docx
format-key-session.docx
I can't open docx files, can you convert them please to pdf or something else.
another thing to try is to convert your application to a normal windows application and
not to a web application for testing only to eleminate a rights problem with the web environment.
another thing to try is to convert your application to a normal windows application and
not to a web application for testing only to eleminate a rights problem with the web environment.
ASKER
Ok done, and I had a win test app (RS232), there is 2 RS232 class , that RS232 class is the same one as the one used in encodingV1, a bit different than the one in this app.
Also the btn testdll is for me when testing the ImportDLL, but for this you need at least one encoder and the API dll .
Thank's
Alan
format-key-session---paket-view-.pdf
format-key-session---paket-view.pdf
format-key-session.pdf
Form1.vb
CRs232.vb
AssemblyInfo.vb
rs232.vb
RS232.vbproj
Also the btn testdll is for me when testing the ImportDLL, but for this you need at least one encoder and the API dll .
Thank's
Alan
format-key-session---paket-view-.pdf
format-key-session---paket-view.pdf
format-key-session.pdf
Form1.vb
CRs232.vb
AssemblyInfo.vb
rs232.vb
RS232.vbproj
Hello, can you change the code of the openport function
Sub openport(ByVal stringhold As String)
Dim comhold As New Rs232 'class that handles the com port connections
Try
comhold.Port = 3
comhold.BaudRate = 9600
comhold.Open()
'comhold.Write(stringhold)
Dim myTestByte(3) As Byte
myTestByte(0) = &H2 '<STX>
myTestByte(1) = &H1 '1
myTestByte(2) = &H5 '<ENQ>
myTestByte(3) = &H0 '<NULL>
comhold.Write(myTestByte)
' lblmessage.Text = comhold.Read(5).ToString
Catch ex As Exception
Dim errorhold As String
errorhold = ex.Message
End Try
comhold.Close()
End Sub
ASKER
Hello melmers,
I did it , didn't work but I think we are in right direcction nut not sending the corretc tring
sending the command throught the dll import show
00000034 26.03.2011 14:49:56.539 +0.0 IRP_MJ_WRITE DOWN 0x00000000 7e ff 03 80 31 05 00 67 32 7e ~...1..g2~
and sending throug the test app as you suggested :
00000042 26.03.2011 14:53:06.119 +0.0 IRP_MJ_WRITE DOWN 0x00000000 02 01 05 00 ....
now the only valus that we sent to the incoder is "1" or "&H1 ' it should show at 31, it seem we not converting the correct format , looking tgrough the ASPM application that what I got
<20110326150608.861 TX>
#7E#FF<ETX>#80#31<ENQ><NUL >#67#32#7E
but execpt this , all seem correct , when we convert the command in the corretc format we should get a the response fromt the encoder .
I will look into google if I can find a lead on how 1 can = 31
I attched the 3 test file , in txt format to amke it easy to read.
thank's
Alan
format-dllImport.txt
format-testApp.txt
format-key-2-ASCII.txt
I did it , didn't work but I think we are in right direcction nut not sending the corretc tring
sending the command throught the dll import show
00000034 26.03.2011 14:49:56.539 +0.0 IRP_MJ_WRITE DOWN 0x00000000 7e ff 03 80 31 05 00 67 32 7e ~...1..g2~
and sending throug the test app as you suggested :
00000042 26.03.2011 14:53:06.119 +0.0 IRP_MJ_WRITE DOWN 0x00000000 02 01 05 00 ....
now the only valus that we sent to the incoder is "1" or "&H1 ' it should show at 31, it seem we not converting the correct format , looking tgrough the ASPM application that what I got
<20110326150608.861 TX>
#7E#FF<ETX>#80#31<ENQ><NUL
but execpt this , all seem correct , when we convert the command in the corretc format we should get a the response fromt the encoder .
I will look into google if I can find a lead on how 1 can = 31
I attched the 3 test file , in txt format to amke it easy to read.
thank's
Alan
format-dllImport.txt
format-testApp.txt
format-key-2-ASCII.txt
0x31 is the hex value for the ascii character 1
So in that case 1 is "text" with not a raw value.
I should not matter if you send one character at a time or all at once.
As you are finding, it seems the actual binary values you are sending are not correct, not the way you are connectingor sending.
So in that case 1 is "text" with not a raw value.
I should not matter if you send one character at a time or all at once.
As you are finding, it seems the actual binary values you are sending are not correct, not the way you are connectingor sending.
At a quick look at the spec doc.
The command format : <STX>ddssff[data]<ETX>cc
where STX and ETX will be binary data 0x02 and 0x03 as in the doc
dd ss ff [data] cc are ASCII values
See the doc for more datail....
example
<STX>0101B<ETC>cc
in hex would be
0x02 0x30 0x31 0x30 0x31 0x42 0x03 cc
Where cc is the check byte that needs to be calculated.
The doc stats the <stx> is not in the check, so in my example I would need to xor : 0x30 0x31 0x30 0x31 0x42 0x03 = 0x41
The check byte is 2 ASSCI of its value.
ie: 0x41 binary needs to convert to ascii "41", which in its hex/binary form is
0x34 0x31
so the completed command string in hex is
0x02 0x30 0x31 0x30 0x31 0x42 0x03 0x34 0x31
The command format : <STX>ddssff[data]<ETX>cc
where STX and ETX will be binary data 0x02 and 0x03 as in the doc
dd ss ff [data] cc are ASCII values
See the doc for more datail....
example
<STX>0101B<ETC>cc
in hex would be
0x02 0x30 0x31 0x30 0x31 0x42 0x03 cc
Where cc is the check byte that needs to be calculated.
The doc stats the <stx> is not in the check, so in my example I would need to xor : 0x30 0x31 0x30 0x31 0x42 0x03 = 0x41
The check byte is 2 ASSCI of its value.
ie: 0x41 binary needs to convert to ascii "41", which in its hex/binary form is
0x34 0x31
so the completed command string in hex is
0x02 0x30 0x31 0x30 0x31 0x42 0x03 0x34 0x31
ASKER
Hello M walker and thank's for the help ....
the first time that I work with hex and serial so learning my way around.
I try to convert the hex string to byte with something like this but keep geeting an exception ...
========================
Dim Input As String = " 02 30 31 30 31 42 03 34 31 "
Dim myTestByte As Byte()
For x = 0 To (Input.Length) / 5
myTestByte(x) = Convert.ToByte(Input.Subst ring(x * 5, 4), 16)
Next
Exception : "Could not find any recognizable digits."
=======================
any idea what I'm missing , again not familiar with hex so I look at a couple of C# sample to do this
thank's
Alan
the first time that I work with hex and serial so learning my way around.
I try to convert the hex string to byte with something like this but keep geeting an exception ...
========================
Dim Input As String = " 02 30 31 30 31 42 03 34 31 "
Dim myTestByte As Byte()
For x = 0 To (Input.Length) / 5
myTestByte(x) = Convert.ToByte(Input.Subst
Next
Exception : "Could not find any recognizable digits."
=======================
any idea what I'm missing , again not familiar with hex so I look at a couple of C# sample to do this
thank's
Alan
Im not a vb person, so dont know the functions.
The tricky bit is the who string is NOT ASCII to start with. The vb lads will now the best way.
Something like this should work as a concept, needs syntax clean up...
Dim MyCommand as Byte()
var STX as Byte
var ECT as Byte
var idx as Interger
var Command As String = "0101B"
var CC as Byte
REM setup the Comand Format characters
STX = &H02
ECT = &H03
REM Build the command binary string
idx = 0;
MyCommand[idx] = STX
idx = idx +1
MyCommand[idx] = Convert.ToByte(Command,Str ingLength( Command))
idx = idx + StringLength(COmmand)
MyCommand[idx] = ECT
REM now calc the check byte
CC = 0
for x = 1 to (Idx - 1)
CC = CC XOR MyCommand[x]
Next
REM convert binary CC to ascii string No idea of the code.... in c i would
BinToHex (TempHexString,CC,1);
Rem Add CC to MyCommand
CC[Idx] = TempHexString[0];
Idx = Idx + 1
CC[Idx] = TempHexString[1];
Idx = Idx + 1;
Now just loop from 0 to (Idx -1) so you Send Idx bytes
RS232 Send MyCommand[loop]
Again, sorry for my lock of VB code syntax so more then happy for the vb people to rewrite with all the correct commands...
The tricky bit is the who string is NOT ASCII to start with. The vb lads will now the best way.
Something like this should work as a concept, needs syntax clean up...
Dim MyCommand as Byte()
var STX as Byte
var ECT as Byte
var idx as Interger
var Command As String = "0101B"
var CC as Byte
REM setup the Comand Format characters
STX = &H02
ECT = &H03
REM Build the command binary string
idx = 0;
MyCommand[idx] = STX
idx = idx +1
MyCommand[idx] = Convert.ToByte(Command,Str
idx = idx + StringLength(COmmand)
MyCommand[idx] = ECT
REM now calc the check byte
CC = 0
for x = 1 to (Idx - 1)
CC = CC XOR MyCommand[x]
Next
REM convert binary CC to ascii string No idea of the code.... in c i would
BinToHex (TempHexString,CC,1);
Rem Add CC to MyCommand
CC[Idx] = TempHexString[0];
Idx = Idx + 1
CC[Idx] = TempHexString[1];
Idx = Idx + 1;
Now just loop from 0 to (Idx -1) so you Send Idx bytes
RS232 Send MyCommand[loop]
Again, sorry for my lock of VB code syntax so more then happy for the vb people to rewrite with all the correct commands...
ASKER
Hi M walker ,
please dont be sorry, this is great that you understand what I am trying to do and show me a way in which it can be done .. even if in C . I know that all those dll's like the one I use in my dllimport fuction to send command to the encoder had being written in C., I dont think i has being dome in a .net format before.
The thing is that I dont know C ..very well , last I did any was years ago in college...I like to try 2 ways .. can you rewite the function above so if would work in a c app (like is REM = Remark..?) , so I can use a converter and hopefully have enought converted to VB.net that I can firgure it out was is left, if I cant then I 'll open another question and hopefully someone who know both C and VB can help getting it done .
I also sent it to a friend who do a lot of C# and have a better bckground in C than me so hopefully he can get some of the syntax...
also which flavor of C the code is written in ..? need to know that for the converter
thank's
Alan
please dont be sorry, this is great that you understand what I am trying to do and show me a way in which it can be done .. even if in C . I know that all those dll's like the one I use in my dllimport fuction to send command to the encoder had being written in C., I dont think i has being dome in a .net format before.
The thing is that I dont know C ..very well , last I did any was years ago in college...I like to try 2 ways .. can you rewite the function above so if would work in a c app (like is REM = Remark..?) , so I can use a converter and hopefully have enought converted to VB.net that I can firgure it out was is left, if I cant then I 'll open another question and hopefully someone who know both C and VB can help getting it done .
I also sent it to a friend who do a lot of C# and have a better bckground in C than me so hopefully he can get some of the syntax...
also which flavor of C the code is written in ..? need to know that for the converter
thank's
Alan
I will see if I get time and put a quick bit of test code. It will try to do it in stock ansi C (I use Borland/CodeVision C++, but if i use stand c it should convert. OK.
If someone else can get in first, by all means do it as I may not get time and off on a trip for 2 weeks, shortly :)
I should get time later on, but not for a few hours...
If someone else can get in first, by all means do it as I may not get time and off on a trip for 2 weeks, shortly :)
I should get time later on, but not for a few hours...
ASKER
thank's
.. ya I try my converter and didn't go very far, also I open a new question hopefully someone can bring some good input...
IIf you read the previous comment this is something that I am adding to a running app(hotel management system for small budget hotel ) and went into in a bit of a rush.. .. one hotel is waiting for me to get it running so they wont have to use 2 systems , one for RMS and the other for the encoder, the enocoder cpy is refusing to give me any Api or help because they ask that small hotel for a small fortune to do it themself ... boderline balkmailing if you ask me ...
Anyway thank's a lot for your help
and if you ever got to Malaysia ... look ne up .. can take you to some great place if you like scuba .... :) Like around Tioman Island ... just overnight from where I leave .. South China Sea . one of the best to dive into ....!!
Alan
.. ya I try my converter and didn't go very far, also I open a new question hopefully someone can bring some good input...
IIf you read the previous comment this is something that I am adding to a running app(hotel management system for small budget hotel ) and went into in a bit of a rush.. .. one hotel is waiting for me to get it running so they wont have to use 2 systems , one for RMS and the other for the encoder, the enocoder cpy is refusing to give me any Api or help because they ask that small hotel for a small fortune to do it themself ... boderline balkmailing if you ask me ...
Anyway thank's a lot for your help
and if you ever got to Malaysia ... look ne up .. can take you to some great place if you like scuba .... :) Like around Tioman Island ... just overnight from where I leave .. South China Sea . one of the best to dive into ....!!
Alan
This is the c function to build a command from the "user text" and calc and add the CC bytes
It assumes the command will start the STC and end with ETC (so it may need tuning for other commands from the docs
CMD will be the request you want to send... from the example in the docs
CMD -> "09R" : Not this should be as is ASCII.
The full binary command built would be the binary ready to send on the RS232 Line.
The Hex Readable version is : 02 30 39 52 03 35 38
/*
Target : Points to a byte Array big enough to hold the command
CMD : Points to a character Array with the command NULL terminated
Return : length of the Target Command to send to the remote Device
*/
int FormatCommand (byte *Target, char *CMD)
{
byte STX = 0x02;
byte ECT = 0x03;
int Idx = 0;
int Loop;
byte CC;
// Move STX into array
Target[Idx++] = STX;
// Move "user" command into array
for (Loop = 0; Loop < strlen (CMD); Loop++)
Target[Idx++] = CMD[Loop];
// Move ECT into array
Target[Idx++] = ECT;
// Calc CC : XOR all bytes (seed with 0) execpt the first byte
CC = 0;
for (Loop = 1; Loop < Idx; Loop++)
CC ^= Target[Loop];
// Get CC high nibble and convert to hex/ascii
if ((CC >> 4) > 9) Target[Idx++] = 'A'+(CC >> 4); else Target[Idx++] = '0'+(CC >> 4);
// Get CC low nibble and convert to hex/ascii
if ((CC & 0x0F) > 9) Target[Idx++] = 'A'+(CC & 0x0F); else Target[Idx++] = '0'+(CC & 0x0F);
return Idx;
}
It assumes the command will start the STC and end with ETC (so it may need tuning for other commands from the docs
CMD will be the request you want to send... from the example in the docs
CMD -> "09R" : Not this should be as is ASCII.
The full binary command built would be the binary ready to send on the RS232 Line.
The Hex Readable version is : 02 30 39 52 03 35 38
/*
Target : Points to a byte Array big enough to hold the command
CMD : Points to a character Array with the command NULL terminated
Return : length of the Target Command to send to the remote Device
*/
int FormatCommand (byte *Target, char *CMD)
{
byte STX = 0x02;
byte ECT = 0x03;
int Idx = 0;
int Loop;
byte CC;
// Move STX into array
Target[Idx++] = STX;
// Move "user" command into array
for (Loop = 0; Loop < strlen (CMD); Loop++)
Target[Idx++] = CMD[Loop];
// Move ECT into array
Target[Idx++] = ECT;
// Calc CC : XOR all bytes (seed with 0) execpt the first byte
CC = 0;
for (Loop = 1; Loop < Idx; Loop++)
CC ^= Target[Loop];
// Get CC high nibble and convert to hex/ascii
if ((CC >> 4) > 9) Target[Idx++] = 'A'+(CC >> 4); else Target[Idx++] = '0'+(CC >> 4);
// Get CC low nibble and convert to hex/ascii
if ((CC & 0x0F) > 9) Target[Idx++] = 'A'+(CC & 0x0F); else Target[Idx++] = '0'+(CC & 0x0F);
return Idx;
}
ASKER
hello M walker,
thank's so much , the converter converted your code to a vb function with no prob it seem .. I mean no error show .
But as always not to sure if all is corretc . I am having a difficulties with the "char *CMD" in the vb function is show as this
Private Function FormatCommand(ByVal Target() As Byte, ByVal CMD() As SByte) As Integer
COM being the data that we send to the RS232 (encoder) depending on the encoder it could be like in the doc"0103E" jjust to read the card E =Read card .
The converter convert CMD as Sbytes and I'm having difficulty in converting ""0103E" into anything that Sbyte will accepted. I s this converstion correct , I thought I understood what you meant here:
CMD will be the request you want to send... from the example in the docs
CMD -> "09R" : Not this should be as is ASCII.
I keep getting this error with obj:
"Value of type '1-dimensional array of Byte' cannot be converted to '1-dimensional array of SByte' because 'Byte' is not derived from 'SByte"
I tried many varation of :
Dim enComd As String = "0103E"
'Dim encoding As New System.Text.ASCIIEncoding( )
'Dim objAs Byte() = encoding.GetBytes(enComd)
Dim obj As Byte() = StringToByteArray(enComd)
Public Shared Function StringToByteArray(ByVal input As String) As Byte()
Return Encoding.Unicode.GetBytes( String.Emp ty + input)
End Function
'Public Shared Function StrToByteArray(ByVal str As String) As Byte()
'Dim encoding As New System.Text.ASCIIEncoding( )
' Return encoding.GetBytes(str)
' End Function
Dim myTestByte(1) As Byte
myTestByte(0) = &H1 '<STX>
idxsent = hexconv.FormatCommand(myTe stByte, obj)
/- - - - -
comhold.Write(myTestByte)
txtRX.Text = comhold.Read(5).ToString
Just want to make sure that Sbyte is the format that CMD has to be
thank's
Alan
thank's so much , the converter converted your code to a vb function with no prob it seem .. I mean no error show .
But as always not to sure if all is corretc . I am having a difficulties with the "char *CMD" in the vb function is show as this
Private Function FormatCommand(ByVal Target() As Byte, ByVal CMD() As SByte) As Integer
COM being the data that we send to the RS232 (encoder) depending on the encoder it could be like in the doc"0103E" jjust to read the card E =Read card .
The converter convert CMD as Sbytes and I'm having difficulty in converting ""0103E" into anything that Sbyte will accepted. I s this converstion correct , I thought I understood what you meant here:
CMD will be the request you want to send... from the example in the docs
CMD -> "09R" : Not this should be as is ASCII.
I keep getting this error with obj:
"Value of type '1-dimensional array of Byte' cannot be converted to '1-dimensional array of SByte' because 'Byte' is not derived from 'SByte"
I tried many varation of :
Dim enComd As String = "0103E"
'Dim encoding As New System.Text.ASCIIEncoding(
'Dim objAs Byte() = encoding.GetBytes(enComd)
Dim obj As Byte() = StringToByteArray(enComd)
Public Shared Function StringToByteArray(ByVal input As String) As Byte()
Return Encoding.Unicode.GetBytes(
End Function
'Public Shared Function StrToByteArray(ByVal str As String) As Byte()
'Dim encoding As New System.Text.ASCIIEncoding(
' Return encoding.GetBytes(str)
' End Function
Dim myTestByte(1) As Byte
myTestByte(0) = &H1 '<STX>
idxsent = hexconv.FormatCommand(myTe
/- - - - -
comhold.Write(myTestByte)
txtRX.Text = comhold.Read(5).ToString
Just want to make sure that Sbyte is the format that CMD has to be
thank's
Alan
My code wanted CMD to "point" to a string ie : Dim enComd As String = "0103E"
Note: My call was expecting a pointer to the string, not the actual string.
In the case of the CMD, this could just be the string as its not changed.
In the case of Target it needs to point to the target as it gets updated. (Again you could make these global variables)
You could cheat and remove that from the function call and make it a global variable.
eg: Global variable
Dim CMD as String;
In your code
CMD = "0103E"
then call the function.
Note: My call was expecting a pointer to the string, not the actual string.
In the case of the CMD, this could just be the string as its not changed.
In the case of Target it needs to point to the target as it gets updated. (Again you could make these global variables)
You could cheat and remove that from the function call and make it a global variable.
eg: Global variable
Dim CMD as String;
In your code
CMD = "0103E"
then call the function.
ASKER
Hi M walker,
I did as you suggester, got CMD as a global and temoved it from the function for now ...
I mad another change instead of :
For [Loop] = 0 To CMD.Length - 1
Target(Idx) =CMD([Loop])
Idx += 1
Next [Loop]
I change to
For [Loop] = 0 To CMD.Length - 1
Target(Idx) = AscW(CMD([Loop]))
Idx += 1
Next [Loop]
so we get the string char as a unicode value ...
when I declare Target() as byte , got to make sure that it is not nothing and the value (x) ie equal as we got in :
Target(Idx)
so I got it to run and compile , later on will go the office and test it with the encoder ..
again thank's so much and I post result after testing with the encoder .
Alain
I did as you suggester, got CMD as a global and temoved it from the function for now ...
I mad another change instead of :
For [Loop] = 0 To CMD.Length - 1
Target(Idx) =CMD([Loop])
Idx += 1
Next [Loop]
I change to
For [Loop] = 0 To CMD.Length - 1
Target(Idx) = AscW(CMD([Loop]))
Idx += 1
Next [Loop]
so we get the string char as a unicode value ...
when I declare Target() as byte , got to make sure that it is not nothing and the value (x) ie equal as we got in :
Target(Idx)
so I got it to run and compile , later on will go the office and test it with the encoder ..
again thank's so much and I post result after testing with the encoder .
Alain
I will be away for about 2 weeks, so will see how you go when I get back. More then happy for someone else to take over. Good luck
ASKER
Hi M walker,
I had client's from oversea for the past couple days ... had to give them my attention , but will be able to test on the mifare encoder today ..
I had client's from oversea for the past couple days ... had to give them my attention , but will be able to test on the mifare encoder today ..
ASKER
I run some test last night and it dont match , the HEX dont match .. using the encoder software I run a read card : that what serial monitor got :
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 7E FF 00 DF 0B 17 7E ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~
ÿ.ß..~
the doc show this command to read card
nformation format: <STX>ddssff[data]<ETX>cc
3.3.2 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>
that what I run usin the CMD function and i use ASCII in serail monitor first to see exactly what I was sending DOWN :
20110403184251.335 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110403184257.523 TX>
<STX>0103E<ETX>44
<20110403184439.616 SYS>
COM port is closed
and the HEX ..023031303345033434
So looking at the doc :
STX (0x02): Tag the beginning of the data.
ETX (0x03): Tag the end of the data.
it seem correct for seem so far off of what the encodersoftware does like why all those FF before the command string and I notice that whatever I use the Mifare encoder or orbita both seem to use the same "" FF 7E FF "" who translate to those funny char ÿ~ .....
it clearly state that is should begin with STX or 02 but didnyt see any 02 in the string send by the encoder software ...??
Also thsi setting , I can not duplicate
008832: I/O Request (DOWN), 29.03.2011 16:47:53.434 +0.0
IOCTL_SERIAL_SET_TIMEOUTS: Set timeouts
ReadIntervalTimeout=429496 7295
4294967295 is one number to many or ReadIntervalTimeout cannot be set as integer
moving forward but still something is missing pieces...
Alan
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 7E FF 00 DF 0B 17 7E ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~
ÿ.ß..~
the doc show this command to read card
nformation format: <STX>ddssff[data]<ETX>cc
3.3.2 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>
that what I run usin the CMD function and i use ASCII in serail monitor first to see exactly what I was sending DOWN :
20110403184251.335 SYS>
Purge the serial port: RXCLEAR, TXCLEAR
<20110403184257.523 TX>
<STX>0103E<ETX>44
<20110403184439.616 SYS>
COM port is closed
and the HEX ..023031303345033434
So looking at the doc :
STX (0x02): Tag the beginning of the data.
ETX (0x03): Tag the end of the data.
it seem correct for seem so far off of what the encodersoftware does like why all those FF before the command string and I notice that whatever I use the Mifare encoder or orbita both seem to use the same "" FF 7E FF "" who translate to those funny char ÿ~ .....
it clearly state that is should begin with STX or 02 but didnyt see any 02 in the string send by the encoder software ...??
Also thsi setting , I can not duplicate
008832: I/O Request (DOWN), 29.03.2011 16:47:53.434 +0.0
IOCTL_SERIAL_SET_TIMEOUTS:
ReadIntervalTimeout=429496
4294967295 is one number to many or ReadIntervalTimeout cannot be set as integer
moving forward but still something is missing pieces...
Alan
Back on deck....
With your last post was the FF from a read the worked from 3rd party software? Does the serial port monitor set to the correct baud etc (it should be as it should see the hand shack and com port settings).
Focus on the hex not the asci codes. the 'y' charcter is just the best asci it could find for the value 0xFF (255 dec).
Can you dump a full log of a card read from the working software.
Cheers
With your last post was the FF from a read the worked from 3rd party software? Does the serial port monitor set to the correct baud etc (it should be as it should see the hand shack and com port settings).
Focus on the hex not the asci codes. the 'y' charcter is just the best asci it could find for the value 0xFF (255 dec).
Can you dump a full log of a card read from the working software.
Cheers
ASKER
Hello M_wlaker,
Hope that you had a good trip and welcome back ...
I also had to go away but on a different project ...jjust back and will be working on the encoder tomorrow morning ( Monday morning for us) .
Attached is a full log of a read card info for the encoder software, it return name ..etc.. but those come from the DB , it only get the room number from the card I beleived..
Also during my trip I keep searching and come accros an app that might be interesting to look at , it is open software at SourceForge made in C# and used to write drivers for serial com , it is call AnySeraiPort / http://www.anyserialport.com/
The log I got from serial-monitor-professiona l-dms , pretty good app to monitor traffice to and from your serial: .
I will install AnySerialPort tomorrow and see if I can talk to the encoder. {Any Serial Port is a handy, simple serial port programming language specially designed to simplify the development of RS232 based applications. } and it said that simplify many task's like string data to byte array..etc... take a look I'll very interested to get your opinion ...
Cheer's
Alan
.
ADEM-nead-card.txt
ADEM-nead-card-DATA-VIEW.txt
ADEM-new-room-card.txt
Hope that you had a good trip and welcome back ...
I also had to go away but on a different project ...jjust back and will be working on the encoder tomorrow morning ( Monday morning for us) .
Attached is a full log of a read card info for the encoder software, it return name ..etc.. but those come from the DB , it only get the room number from the card I beleived..
Also during my trip I keep searching and come accros an app that might be interesting to look at , it is open software at SourceForge made in C# and used to write drivers for serial com , it is call AnySeraiPort / http://www.anyserialport.com/
The log I got from serial-monitor-professiona
I will install AnySerialPort tomorrow and see if I can talk to the encoder. {Any Serial Port is a handy, simple serial port programming language specially designed to simplify the development of RS232 based applications. } and it said that simplify many task's like string data to byte array..etc... take a look I'll very interested to get your opinion ...
Cheer's
Alan
.
ADEM-nead-card.txt
ADEM-nead-card-DATA-VIEW.txt
ADEM-new-room-card.txt
ASKER
Hi ,
I dind 't abandon this question and still workiing on a solution ...it seem that using AnySerialPort make it a bit more easy but the main problem is the lack of documentation on how to communicate with those encoders ... if I follow the RS 232 documentation that I got even following m_walker conv code , or another one that I wrote for AnySP the string of bytes (HEX) that we send is different of what we sent using the dll who come with the encoder using dll import and not because the convertion and XOR is wrong but the string is , the doc said to use for " ReadcardzNumber " for exemple : "<STX>0103E<ETX>CC , but for the same call, what is coming from the dll import look's like " "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~ÿ.ß..~" so of course the HEX will be different : and each . represent a tag so looking at the hex it translate to : " ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~ÿ<NUL>ß<VT ><ETB>~" OR IN HEX "" FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 7E FF 00 DF 0B 17 7E "" .
Confusing ... like we dealing with a different language to begin with ...
Alan
I dind 't abandon this question and still workiing on a solution ...it seem that using AnySerialPort make it a bit more easy but the main problem is the lack of documentation on how to communicate with those encoders ... if I follow the RS 232 documentation that I got even following m_walker conv code , or another one that I wrote for AnySP the string of bytes (HEX) that we send is different of what we sent using the dll who come with the encoder using dll import and not because the convertion and XOR is wrong but the string is , the doc said to use for " ReadcardzNumber " for exemple : "<STX>0103E<ETX>CC , but for the same call, what is coming from the dll import look's like " "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~ÿ.ß..~" so of course the HEX will be different : and each . represent a tag so looking at the hex it translate to : " ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ~ÿ<NUL>ß<VT
Confusing ... like we dealing with a different language to begin with ...
Alan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Goog luck. I was thinking it was the wrong command set, but that explains it.
ASKER
ya, but with my limited knowledge in c++ that is not going to be easy ... and I did a little or recherche on EE , I dont think it is going to be easy ,you cannot convert from VC6 to C# it is to distant... I contact Silicom lab again and ask them if they have sample but in c# ..
Hope all is well for you and again thanak's for all the help and support, I dont close this question yet because once I can connect to the encoder I want to try you convertion function ..
Alan
Hope all is well for you and again thanak's for all the help and support, I dont close this question yet because once I can connect to the encoder I want to try you convertion function ..
Alan
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
system.text.asciiencoding.
MSDN Text ASCIIEncoder