?
Solved

Retrieving the Appropriate Bits From Data

Posted on 2003-11-25
9
Medium Priority
?
250 Views
Last Modified: 2012-05-04
Hi All,

I have a problem. I will be using VB6 to code an application to retrieve the appropriate bits from the data. This application will communicate with Device 1, whilst Device 2 can only communicate with Device 1. The application in the PC will always poll Device 1 for data, whilst Device 1 will poll Device 2 for data. The data is stored in the buffer of the device. The protocol is as follows:-

<Head><Type><Level><ID><Command><Length><Data>
    01         01       01       01         4fH            n        12bytes

When <Level> = 2, this show that PC is polling for Device 2 data. Device 1 will start to poll data in Device 2 buffer. The data will then transfer from Device 2 buffer to Device 1 buffer. how can I code in VB to send this command to poll for device 2. After getting the data, how can i abstract the last 6 bytes from the data and drop the first 6 bytes?

thanks you
0
Comment
Question by:wmchew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 672 total points
ID: 9816675
I think you will have to explain more about your scenario.

Are you able to communicate OK with your devices?

Assuming you are, it appears to be a matter of manipulating strings.

If all you need to poll device 2 is to change the level then

Device2Data = Left$(Device1Data,2) & chr$(02) & Mid$(Device1Data, 3)
 
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9816681
And to drop the first 6 bytes

strRestOfBuffer = Mid$(strFullBuffer, 7)

0
 

Author Comment

by:wmchew
ID: 9817244
hi GrahamSkan,

Ok. Let me be more detail. I have this application(coded in VB6) in PC monitoring 2 card access readers. They are both installed on a different floor of a building. These access readers actually stores the swipe card records in the readers. this application will always poll for data from reader in the 1st level(the one nearest PC) whilst PC can only communicate with reader 2 through reader 1.

As you can see from the protocol, when the level = 2, that mean PC wanted to poll data from reader 2(in 2nd level). Then reader 1 will recognise this and poll for data in reader 2 which was stored in buffer. The data was then transferred from reader 2 buffer to reader 1 buffer, finally to PC.

How should I code this part.

Secondly, after getting this data how can I abstract the last 6 bytes of the 12 bytes data?

thanks.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:wmchew
ID: 9817249
BTW, the devices can communicate. and the communication standard is RS485.
0
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 664 total points
ID: 9817405
To send command


dim str as string

str = chr$(1) + chr$(1) + chr$(2) + ....   ' you get the idea here
MSComm1.Output = str


To extract the data

use GrahamSkan's method


ie

dim str as string

str = MSComm1.Input
str = mid$(str, 13, 6)
0
 
LVL 28

Assisted Solution

by:Ark
Ark earned 664 total points
ID: 10161515
      First_six_bits = (lData And &HFFF000) / &H1000
       Second_six_bits = lData And &HFFF&
0
 
LVL 28

Expert Comment

by:Ark
ID: 10161520
PS.
or reverse according BigEndian/LittleIndian bytes order
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question