From: Henning on

"Schmidt" <sss(a)online.de> skrev i meddelandet
news:hu3n2c$h1p$1(a)speranza.aioe.org...
>
> "Henning" <computer_hero(a)coldmail.com> schrieb im Newsbeitrag
> news:hu3lbr$to0$1(a)news.eternal-september.org...
>
>> The Timers are running ok now, without any this or that, just
>> SetTimer/KillTimer.
> Yep - works too.
>
>> Next up is using mscomm32.ocx directly from code by
>> reference. I know I read somewhere that someone had
>> a .dll replacing the .ocx, but hasn't found it again...yet.
> IMO the suggestion was, to look up on Planetsourcecode,
> for a near "full blown" implementation, not sure though.
>
> If this helps you (and if your device requires only simple
> communication - without any DTR-stuff and things like
> that) - this is what we use here on small 3.5" embedded
> AtomCPU-PC-boards, running linux/wine+a small VB-App
> "on top", to talk to "machines" over Rs232:
>
>
> Olaf

What I really need to do is following, that works with MSComm on a Form:
It is a master/slave communication thru a RS232/RS485 simplex converter. DTR
is used to switch RS485 Tx/Rx.
I send a Allow2Send packet, and the slave respond either Ack = nothing to
send, or a a packet with data.
I have a lot of textboxes to track what is sent and received while getting
it to work.

The first byte received is the packet length, so I first read only one byte
from the port.

Private Sub MSComm1_OnComm()
Dim rx As String
Dim srx As String
Dim i As Long
Dim msg As Integer
Dim Data As String
Dim z As String
Dim realSize As Integer
Dim TSRE As Boolean

Timer1.Enabled = False
' For i = 1 to len(buffer):print right$("0" &
hex$(asc(mid$(buffer,i,1))),2);:next:print
With MSComm1
msg = .CommEvent
If msg > 0 Then
Select Case msg
Case Is > 1000
If cmdLog2File.BackColor = vbGreen Then
Print #fil, Time & " * CommError: " & msg
End If
Case Is = comEvSend
While Not GetPortBit(UART_LSR, TEMT) 'wait till last byte
transmitted
Wend
TxOn = False 'signal Send routine last byte sent
End Select
End If
If Not FirstByte Then
.InputLen = 1
buffer = .Input
If Len(buffer) = 1 Then
RxSize = Asc(buffer)
Select Case RxSize
Case 3, 4, 13, 15 'allowed packet lengths
txtRxSize.Text = RxSize
FirstByte = True
.InputLen = RxSize + 1
LedRxSize.BackColor = vbGreen
LedFirstByte.BackColor = vbGreen
Case Else
FirstByte = False
LedRxSize.BackColor = vbRed
LedRxSize.Caption = RxSize
LedFirstByte.BackColor = vbRed
realSize = RxSize
RxSize = 0
.InBufferCount = 0
struRx.msgLen = RxSize
TxErrAck = TxErrAck + 1
txtErrAck.Text = TxErrAck
If cmdLog2File.BackColor = vbGreen Then
Print #fil, Time & " TotPoll= " & txtTxAllow.Text & " : TotErr=
" & txtErrAck.Text & " - ErrSize= " & realSize
End If
End Select
End If
Else
If RxSize > 0 Then
If .InBufferCount > RxSize Then
buffer = buffer & .Input
RxBuf = Left$(buffer, RxSize + 2)
For i = 1 To Len(RxBuf)
srx = srx & Right$("0" & Hex$(Asc(Mid$(RxBuf, i, 1))), 2)
Next
With struRx
Data = Mid$(RxBuf, 2, 1)
txtRxDest.Text = Right$("0" & Hex$(Asc(Data)), 2)
.msgDest = Asc(Data)
Data = Mid$(RxBuf, 3, 1)
txtRxSrc.Text = Right$("0" & Hex$(Asc(Data)), 2)
.msgSrc = Asc(Data)
Data = Mid$(RxBuf, 4, 1)
txtRxType.Text = Right$("0" & Hex$(Asc(Data)), 2)
.msgType = Asc(Data)
Data = Mid$(RxBuf, RxSize + 2, 1)
txtRxCRC.Text = Right$("0" & Hex$(Asc(Data)), 2)
.crc = Asc(Data)
Select Case RxSize
Case 3
If .msgType <> Ack Then
z = Time & " - " & srx
lstReceive.AddItem (z)
If cmdLog2File.BackColor = vbGreen Then
Print #fil, z
End If
End If
Case 4
.msgDataLen = 0
.msgType = Asc(Mid$(RxBuf, RxSize, 1))
z = Time & " - " & srx
lstReceive.AddItem (z)
If cmdLog2File.BackColor = vbGreen Then
Print #fil, z
End If
If Executing Then
.InTime = Now()
If .msgType = AlarmSent Then
struTx.ExecTime = .InTime
SetExecuted
End If
End If
'0D0001030008F05008FFFF0226FF17 (normal 13 byte+2 data packet)
Case 13
.msgDataLen = Asc(Mid$(RxBuf, 6, 1))
.RaType = Asc(Mid$(RxBuf, 7, 1))
.RaSrc = 256& * Asc(Mid$(RxBuf, 8, 1)) + Asc(Mid$(RxBuf, 9,
1))
.RaDest = 256& * Asc(Mid$(RxBuf, 10, 1)) + Asc(Mid$(RxBuf, 11,
1))
.RaAlarmType = Asc(Mid$(RxBuf, 12, 1))
.RaCode = Asc(Mid$(RxBuf, 13, 1))
.RaDummy = Asc(Mid$(RxBuf, 14, 1))
If Executing Then
If .RaSrc = struTx.RaDest Then
struTx.AckTime = Now()
SetAlarmAcked
End If
End If
z = Time & " - " & srx
lstReceive.AddItem (z)
If cmdLog2File.BackColor = vbGreen Then
Print #fil, z
End If
Executing = False
SendAck
LedTxOn.BackColor = vbRed
Case 15
.msgDataLen = Asc(Mid$(RxBuf, 6, 1))
.RaType = Asc(Mid$(RxBuf, 7, 1))
.RaSrc = 256& * Asc(Mid$(RxBuf, 8, 1)) + Asc(Mid$(RxBuf, 9,
1))
.RaDest = 256& * Asc(Mid$(RxBuf, 10, 1)) + Asc(Mid$(RxBuf, 11,
1))
.RaAlarmType = Asc(Mid$(RxBuf, 12, 1))
.RaCode = Asc(Mid$(RxBuf, 13, 1))
.RaDummy = Asc(Mid$(RxBuf, 14, 1))
.TREXLastAck = Asc(Mid$(RxBuf, 15, 1)) * 256 + Asc(Mid$(RxBuf,
16, 1))
z = Time & " - " & srx
lstReceive.AddItem (z)
If cmdLog2File.BackColor = vbGreen Then
Print #fil, z
End If
SendAck
Case Else
LedRxSize.BackColor = vbRed
LedRxSize.Caption = RxSize
For i = 1 To Len(RxBuf)
txtRxSizeErr.Text = txtRxSizeErr.Text & Right$("0" &
Hex$(Asc(Mid$(buffer, i, 1))), 2)
Next
End Select
End With
RxSize = 0
FirstByte = False
LedFirstByte.BackColor = vbRed
End If
Else
FirstByte = False
LedFirstByte.BackColor = vbRed
End If
End If
End With
Timer1.Enabled = True '1 sec. timer to check a DB for a new record to
handle

End Sub

/Henning


From: David Youngblood on
"Henning" <computer_hero(a)coldmail.com> wrote...
>
> The Timers are running ok now, without any this or that, just
> SetTimer/KillTimer.
>
> Next up is using mscomm32.ocx directly from code by reference. I know I
> read somewhere that someone had a .dll replacing the .ocx, but hasn't
> found it again...yet.

You might try here,
http://www.hardandsoftware.com/
Under software downloads you'll find a vb6 class module named mComm. I've
not used it. I use a VISA library (standard dll) that works with GPIB,
Serial, VXI, LAN and USB instruments.

David


From: Tom Shelton on
Schmidt expressed precisely :
> "Tom Shelton" <tom_shelton(a)comcast.invalid> schrieb im Newsbeitrag
> news:hu3p14$ftv$1(a)news.eternal-september.org...
>
>> I was going to respond point-by-point, but this is
>> just becomming rediculous.
> Yep.
>
>> You are reading stuff into my reply ...
> As you say, ridiculous...
>
> You already statet yourself (some time ago),
> that you do not use VBclassic anymore - so why do
> you *post* here at all (nothing against "silent lurking"),
> if all you have to offer for users who *do use*
> Vbclassic is: "how one could implement the
> same thing in a different language" - that's just not
> sufficient, and it's off-topic, sorry.

See you still are not reading my post. I did not tell them how to
implement it in a different language. I was makin suggestions on how
to implement something like what exists in a different set of libraries
in VB6. Did you not read my post? I could just as well have said to
implement something like a map in C++... I could write code, but I
figured a general discription and the api's involved would be enough...

In NO part of my post or any in this thread have I discussed how I
would implement this in .NET.

--
Tom Shelton


From: Henning on

"Tom Shelton" <tom_shelton(a)comcast.invalid> skrev i meddelandet
news:hu404i$fi0$1(a)news.eternal-september.org...
> Schmidt expressed precisely :
>> "Tom Shelton" <tom_shelton(a)comcast.invalid> schrieb im Newsbeitrag
>> news:hu3p14$ftv$1(a)news.eternal-september.org...
>>
>>> I was going to respond point-by-point, but this is
>>> just becomming rediculous.
>> Yep.
>>
>>> You are reading stuff into my reply ...
>> As you say, ridiculous...
>>
>> You already statet yourself (some time ago),
>> that you do not use VBclassic anymore - so why do
>> you *post* here at all (nothing against "silent lurking"),
>> if all you have to offer for users who *do use*
>> Vbclassic is: "how one could implement the
>> same thing in a different language" - that's just not
>> sufficient, and it's off-topic, sorry.
>
> See you still are not reading my post. I did not tell them how to
> implement it in a different language. I was makin suggestions on how to
> implement something like what exists in a different set of libraries in
> VB6. Did you not read my post? I could just as well have said to
> implement something like a map in C++... I could write code, but I
> figured a general discription and the api's involved would be enough...
>
> In NO part of my post or any in this thread have I discussed how I would
> implement this in .NET.
>
> --
> Tom Shelton
>
>
Why mention .Nxt at all??? I know nothing about that language, and I don't
want to know! There is no need to bring anything involving that language
into this group, it's to no help at all. If I were using it and had a
problem, I would certainly *not* post it here.

/Henning