From: Henning on

"Michael" <mqiqcqhqaqeqlqhqiqmqsq(a)qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> skrev i
meddelandet news:DQkJg.89774$fV1.25277(a)fe1.news.blueyonder.co.uk...
>
> <btpanek09(a)yahoo.com> wrote in message
> news:1156953650.401271.48120(a)p79g2000cwp.googlegroups.com...
> >
> > Michael wrote:
> >> Hi,
> >>
> >> How do you output binary from the serial prot using MSCOMM? I need to
> >> send
> >> 1011010000000100 to a device.
> >>
> >> Thanks,
> >>
> >> Michael
> >
> > This binary value is represented by the Hex value B404 as shown, each
> > 4 bits translates to a Hex digit.
> > B 4 0 4
> > 1011 0100 0000 0100
> >
> > Set MSCOMM InputMode to 1-ComInputModeBinary
> > create a byte buffer that will contain 2 bytes
> > Dim OutBuf(0 to 1) as Byte
> > OutBuf(0) = &HB4
> > OutBuf(1) = &H04
> > Then send the message....
> > MSCOMM.Output OutBuf
> >
> > Of course you must Initialize and Open the MSCOMM first.
> >
>
> I've hit another slight problem. Once the device has received the data it
> sends back a checksum "&H6A", if the program doesn't receive that it
resends
> the data. This is what I have so far:
>
> Dim outbuf2 As String
> outbuf2 = Hex(MSComm1.Input)
> If outbuf2 = &H6A Then
> Timer1.Enabled = False
> 'carry on with program
> Else 'resend the data
> MSComm1.Output = Outbuf
> End If
>
> When I run the program I get a Mismatch error on the line outbuf2 =
> Hex(MSComm1.Input). Can someone please explain where I'm going wrong? I
> thought letters and numbers could be converted to hexadecimals?
>
> Michael
>
>
Best is to use MSComm1_OnComm() to receive from comport. You do receive the
error because you try to convert nothing to hex. Byte not received yet.

/Henning



From: Michael on

"Henning" <computer_hero(a)coldmail.com> wrote in message
news:44f5e0a7$0$32153$57c3e1d3(a)news3.bahnhof.se...
>
> "Michael" <mqiqcqhqaqeqlqhqiqmqsq(a)qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> skrev
> i
> meddelandet news:DQkJg.89774$fV1.25277(a)fe1.news.blueyonder.co.uk...
>>
>> <btpanek09(a)yahoo.com> wrote in message
>> news:1156953650.401271.48120(a)p79g2000cwp.googlegroups.com...
>> >
>> > Michael wrote:
>> >> Hi,
>> >>
>> >> How do you output binary from the serial prot using MSCOMM? I need to
>> >> send
>> >> 1011010000000100 to a device.
>> >>
>> >> Thanks,
>> >>
>> >> Michael
>> >
>> > This binary value is represented by the Hex value B404 as shown, each
>> > 4 bits translates to a Hex digit.
>> > B 4 0 4
>> > 1011 0100 0000 0100
>> >
>> > Set MSCOMM InputMode to 1-ComInputModeBinary
>> > create a byte buffer that will contain 2 bytes
>> > Dim OutBuf(0 to 1) as Byte
>> > OutBuf(0) = &HB4
>> > OutBuf(1) = &H04
>> > Then send the message....
>> > MSCOMM.Output OutBuf
>> >
>> > Of course you must Initialize and Open the MSCOMM first.
>> >
>>
>> I've hit another slight problem. Once the device has received the data it
>> sends back a checksum "&H6A", if the program doesn't receive that it
> resends
>> the data. This is what I have so far:
>>
>> Dim outbuf2 As String
>> outbuf2 = Hex(MSComm1.Input)
>> If outbuf2 = &H6A Then
>> Timer1.Enabled = False
>> 'carry on with program
>> Else 'resend the data
>> MSComm1.Output = Outbuf
>> End If
>>
>> When I run the program I get a Mismatch error on the line outbuf2 =
>> Hex(MSComm1.Input). Can someone please explain where I'm going wrong? I
>> thought letters and numbers could be converted to hexadecimals?
>>
>> Michael
>>
>>
> Best is to use MSComm1_OnComm() to receive from comport. You do receive
> the
> error because you try to convert nothing to hex. Byte not received yet.
>
> /Henning
>
>
>

Ok tried it with the OnComm with this code:
Private Sub MSComm1_OnComm()
Beep
MsgBox MSComm1.Input
Text1.Text = Text1.Text & MSComm1.Input
End Sub
And the msgbox is blank.... Surely something must be there as the event
wouldn't get raised otherwise....
When I increased the RTheshold to more than 1 I got a parity error.

The protocol for the device can be found here:
http://www.marmitek.com/en/software/PROTOCOL.DOC

Michael


From: Jim Mack on
Michael wrote:

> Ok tried it with the OnComm with this code:
> Private Sub MSComm1_OnComm()
> Beep
> MsgBox MSComm1.Input
> Text1.Text = Text1.Text & MSComm1.Input
> End Sub
> And the msgbox is blank.... Surely something must be there as the
> event wouldn't get raised otherwise....
> When I increased the RTheshold to more than 1 I got a parity error.

The firing of the OnComm event doesn't mean that data arrived, it just means something happened. For robustness you must check the .CommEvent value. Only when it's comEvReceive is there data present.

Check (debug.print) the commevent value when the event fires. It could be indicating an error.

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com

From: Michael on

"Jim Mack" <jmack(a)mdxi.nospam.com> wrote in message
news:NOqdnWwXIdGiimvZnZ2dnUVZ_oidnZ2d(a)comcast.com...
Michael wrote:

> Ok tried it with the OnComm with this code:
> Private Sub MSComm1_OnComm()
> Beep
> MsgBox MSComm1.Input
> Text1.Text = Text1.Text & MSComm1.Input
> End Sub
> And the msgbox is blank.... Surely something must be there as the
> event wouldn't get raised otherwise....
> When I increased the RTheshold to more than 1 I got a parity error.

The firing of the OnComm event doesn't mean that data arrived, it just means
something happened. For robustness you must check the .CommEvent value. Only
when it's comEvReceive is there data present.

Check (debug.print) the commevent value when the event fires. It could be
indicating an error.

--

Jim Mack
MicroDexterity Inc
www.microdexterity.com

It's still telling me that data is being received. I'm using PortMon at the
same time and every 2 seconds I get 5 requests for the com ports status from
VB6.exe and an incoming data packet with a length of one.

Michael


From: Henning on

"Michael" <mqiqcqhqaqeqlqhqiqmqsq(a)qbqlquqeqyqoqnqdqeqrq.qcqoq.quqkq> skrev i
meddelandet news:awpJg.90949$fV1.44343(a)fe1.news.blueyonder.co.uk...
>
> "Jim Mack" <jmack(a)mdxi.nospam.com> wrote in message
> news:NOqdnWwXIdGiimvZnZ2dnUVZ_oidnZ2d(a)comcast.com...
> Michael wrote:
>
> > Ok tried it with the OnComm with this code:
> > Private Sub MSComm1_OnComm()
> > Beep
> > MsgBox MSComm1.Input
> > Text1.Text = Text1.Text & MSComm1.Input
> > End Sub
> > And the msgbox is blank.... Surely something must be there as the
> > event wouldn't get raised otherwise....
> > When I increased the RTheshold to more than 1 I got a parity error.
>
> The firing of the OnComm event doesn't mean that data arrived, it just
means
> something happened. For robustness you must check the .CommEvent value.
Only
> when it's comEvReceive is there data present.
>
> Check (debug.print) the commevent value when the event fires. It could be
> indicating an error.
>
> --
>
> Jim Mack
> MicroDexterity Inc
> www.microdexterity.com
>
> It's still telling me that data is being received. I'm using PortMon at
the
> same time and every 2 seconds I get 5 requests for the com ports status
from
> VB6.exe and an incoming data packet with a length of one.
>
> Michael
>
If the received data is a nonprintable binary byte it will not show.
..Input can read the same data from buffer only once.

<aircode>
Private Sub MSComm1_OnComm()
Dim RxBuffer$
Beep
With MSComm1
If .CommEvent > 1000 Then
dummy = MsgBox("Comm Error " & .CommEvent, vbCritical + vbOKOnly)
Exit Sub
End If
Text1.Text = .InBufferCount
If .CommEvent = comEvReceive Then
RxBuffer = .Input
MsgBox Val(RxBuffer)
End If
End Sub

/Henning



First  |  Prev  | 
Pages: 1 2
Prev: Printer-Object again
Next: What is this error ???