Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5988021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:53:59+00:00 2026-05-22T22:53:59+00:00

My application has to connect and receive data from RFID reader for every 2

  • 0

My application has to connect and receive data from RFID reader for every 2 seconds so it has developed on django framework. Here are related lines in views.py:

HOST = '192.168.0.1'
PORT = 50007
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
soc.settimeout(2)
soc.connect((HOST, PORT))
soc.send('tag.db.scan_tags(100)\r\n')
datum = soc.recv(128)

if datum.find("ok") > -1:
    soc.send('tag.read_id()\r\n')
    data = soc.recv(8192)

The application would render received data to a template as {{ data }} if the RFID reader found any RFID tag in its field. The problem occurs when there is no tag in field or tags cannot be read, {{ data }} variable would show nothing on the page.

I want my application able to show the last data that can be read. If there is no new data come, just show the latest one. The data would be changed only if new data come. This will makes my application more stable.

Any suggestion, please? Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:54:00+00:00Added an answer on May 22, 2026 at 10:54 pm

    One of the easier things to do would be to use Django’s cache framework, and store the data in local memory, or memcached, or the database, etc. You could cache any data recieved, and used the cached data if you don’t recieve data, or it’s erroneous or whatever:

    from django.core.cache import cache
    
    # set cached data
    cache.set('data', data)
    # get cached data
    cache.get('data')
    

    You could also store the data other ways, on a model for instance. You should probably move the RFID reading portion out of the view, and use celery (or something else) to run it as a task, save the results, and just use the latest saved data in your view

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application which has to be configurable to connect to Oracle, SQL
My application has a need to let the user choose a date from a
Hi all Im building a android application that requires data from a PHP server.
hy i am developing an application that has to connect to a webserver and
Windows 7 has built in Fax Application. Would it be possible to connect to
Application has an auxiliary thread. This thread is not meant to run all the
Our application has a file format similar to the OpenDocument file format (see http://en.wikipedia.org/wiki/OpenDocument
My application has no forms. It runs by calling Application.Run();
My application has a command line interface, and I'm thinking about using the GNU
My application has just started exhibiting strange behaviour. I can boot it through the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.