Click here to Skip to main content
15,798,508 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello Dear All,

I am facing a problem with convert delphi code to any body help me to get the solution please... please check the code below

m_arTxBfx:Array [0..255] of Byte; //Output Buffer
m_arRxBfx:Array [0..255] of Byte; //Input Buffer


Now I need to convert it

I have tried this way...

but its showing error.......

Please Help me ...

Thanks in Advance

Updated 23-Jul-23 2:42am
Maciej Los 19-Jan-16 15:43pm    
What's the question?
What's an error?

1 solution

You have to write code from scratch, following the same logic. The class you need is System.IO.Ports.SerialPort:
SerialPort Class (System.IO.Ports)[^].

Share this answer
Maciej Los 19-Jan-16 16:23pm    
Short and to the point!
Sergey Alexandrovich Kryukov 19-Jan-16 16:27pm    
Thank you, Maciej.
CPallini 19-Jan-16 16:23pm    
Indeed, 5.
Sergey Alexandrovich Kryukov 19-Jan-16 16:28pm    
Thank you, Carlo.
Moseur 19-Jan-16 21:55pm    
Dear All,

Thanks for your help.

Imports System.IO.Ports
Imports System.Net.Sockets
Imports System.Text

Now in button event
I write this code:

m_arTxBfx(0) = &H7E
m_arTxBfx(1) = m_InputLength + 2
m_XOR = 255
m_SUM = 0
For i = 2 To m_InputLength + 1
m_XOR = m_XOR Xor m_arTxBfx(i)
m_SUM = m_SUM + m_arTxBfx(i)
m_arTxBfx(m_InputLength + 2) = m_XOR
m_SUM = m_SUM + m_XOR
m_SUM = m_SUM And 255
m_arTxBfx(m_InputLength + 3) = m_SUM

temp = "Send: "
For i = 0 To m_InputLength + 3
'temp =Temp+Conversion .Hex (m_arTxBfx(i),2)+' '
txtSend.Multiline = True

myres = 1
Dim inputlength As Integer = m_InputLength + 4

If mySerialPort.IsOpen = True Then
mySerialPort.Write(m_arTxBfx(0), inputlength)
End If

But Its showing error over the line (mySerialPort.Write(m_arTxBfx(0), inputlength)) Please help...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900