Solved

Retrieving the Appropriate Bits From Data

Posted on 2003-11-25
9
216 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
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 168 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 166 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 27

Assisted Solution

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

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now