Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hitlad · May 20, 2012 at 12:17 PM · timeslowarduino

how can i see serial port speed

I'm trying to get input from a stationary bike into Unity. I'm reading from the serial port (at 9600 baud) and it's slowing things down to about 1fps. I've seen the other posts with similar problems but I was already doing the polling from Update (rather than OnGUI) and I've tried slowing down the sampling rate (to no avail).

Presently, I've put the polling in another thread and only using the data when it is updated but that results in a lag. What I would like to do is to see exactly how much time the serial port is taking but I'm not sure how to get the system time in milliseconds in Unity.

Is there a way to do that? Also, any suggestions about serial port reading would be appreciated (I can post up the code if that would be useful). Thanks!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · May 20, 2012 at 12:50 PM 0
Share

How do you read the seial port? Any code samples? Do you use blocking functions? The thread-solution is propably the best, how do you synchronise the thread with Unity's main thread?

avatar image hitlad · May 20, 2012 at 10:47 PM 0
Share

There's a command SerialPort in System.IO.Ports. It's just:

 mySerial = new SerialPort(port, 9600);

to open up a port. It may block (which is why it's slow, probably, and it's what I'm trying to figure out). I'm using a separate thread so the blocking doesn't hold things in the main thread but I'd still like the input to be at a higher rate. I just use a semaphore to sync - no real race condition to worry about.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · May 20, 2012 at 12:32 PM

I don't know if this is what you're looking for, but you can read Time.realtimeSinceStartup - this value is based on the system timer, don't take Time.timeScale into account and is updated even during the update cycle (different from Time.time, which shows the same value during the whole update cycle).

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hitlad · May 20, 2012 at 10:18 PM 0
Share

I'm interested in sub-second resolution (1/100 second) since I'm dealing with things on a frame rate level. Time.time and Time.realtimeSinceStartup both only deal in seconds, which is too slow for me.

avatar image Bunny83 · May 21, 2012 at 02:51 AM 0
Share

Uhmm all time values are in seconds, right, but they are float values. You have a fractional part. When you multiplying the value with 1000 you have milliseconds.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Time.timeScale and Time.fixedDeltaTime 1 Answer

SmoothDamp smoothTime ignored! 1 Answer

On time slow down only player enable to move 2 Answers

Time.timeScale question 1 Answer

how to get smooth slow motion? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges