Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieving the Appropriate Bits From Data

Posted on 2003-11-25
9
Medium Priority
?
257 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
Suggested Courses

610 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