Alas, these days have a headache.

Source: Internet
Author: User

During this time, I was writing control procedures for online electronic locks. the door lock circuit board, floor controller, and smart card reader were all developed by X engineers. Things developed by X engineers had a common drawback: they could not be used properly. Both the reader and the floor controller use serial communication. according to instructions given by X, writing a program is not difficult, so I said that I could finish writing the program in a week when I just received the instructions, it has been more than two weeks since the program was not written. Let's talk about the problem. At first, I was going to encapsulate various operation execution functions into DLL, and I chose the Spcomm Control for reading and writing serial ports, because the smart card reader cannot determine whether the card is successfully written when writing data (the reader writes data and then reads back to determine whether the card is successfully written), the problem arises: I don't know how to use the Spcomm Control to write a function and implement the write/read function on the serial port at the same time. I have tried several methods, but I am not satisfied with them, I found some information on the Internet and consulted the experts. I learned that I want to use thread or callback function .. alas, I have never learned the callback function .. Forget it. Stop writing the DLL .. After the card issuance is completed, it is also very bad .. because I didn't judge whether the card was successfully written .. the user must issue a card before manual query to confirm... haha .. not horizontal .. Let's try it out first .. After writing the read/write card, you will be directed to the online control part of the lock .. This is a headache, and the level is low. In addition, the instructions given by X engineers and the problems of PCB Board itself are added .. It's really a headache .. For now, there are two other problems: one is that after the door status query operation is performed, the floor controller will strike and no longer execute the commands that are immediately received, the software must disable the serial port and then enable it .. Another problem is that when I read the opening record, I normally read 2048 bytes, but how can I read 1995 bytes .. depressed, I ran Shenzhen once yesterday. I tried it normally at X's place (using his program). Why is it abnormal on my computer .. First, I thought it was a problem with the serial port driver file on my computer. However, after changing the driver file, I used the serial port debugging tool copy from X to test it, before running my program, I can normally receive 2048 bytes, but once I run the software, I can only receive 1995 bytes. I rummaged through the Spcomm source code and found that it only lasted 10 seconds while reading the serial port, and it took about 15 seconds for my program to read the door lock record. So I changed the 10 seconds to 25 seconds, come back and test again. Dizzy !! The read speed is 1997 bytes .. Only two more bytes are allowed .. Yes .. Do not use Spcomm. Change the control. The cport control is being tested .. After the test is complete, you have to change it ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.