python-osc icon indicating copy to clipboard operation
python-osc copied to clipboard

Trying to access the OSC packet timestamp

Open nchollan opened this issue 7 years ago • 7 comments

I am trying to acquire the timestamps associated with each packet that I am receiving, rather than using the system time for when each packet is being received. I modified the osc_server function _call_handlers_for_packet, by adding timed_msg.time to the callback(). This seems to be the system time from when the package was received. Is there a way for me to acquire the time stamp from the incoming osc packets?

nchollan avatar Jul 24 '18 15:07 nchollan

packets themselves can send a timestamp, it's a supported type. Cf OSC time tag in the specs http://opensoundcontrol.org/spec-1_0 and get_ttag() in this library. Would that work for you?

attwad avatar Jul 24 '18 15:07 attwad

For the most part get_ttag() seems to work for me. I'm unsure as to why I am receiving the date and time '1900-01-01 00:00:00' as the time stamp for every third packet bundle I get. A similar issue arose for me when attempting to use get_date(). If you have any further insight into what might be causing this issue please let me know. Thank you for the help.

Modifications to source: after utc is defined in get_ttag():

newDate = mktime(utc.timetuple()) newDate=datetime.fromtimestamp(newDate).strftime('%Y-%m-%d %H:%M:%S') return newDate

in get_date(): print(get_ttag(dgram, start_index))

Clip from output: 1900-01-01 00:00:00 1900-01-01 00:00:01 1900-01-01 00:00:01 1900-01-01 00:00:00 1900-01-01 00:00:01 1900-01-01 00:00:01 1900-01-01 00:00:00 1900-01-01 00:00:01 1900-01-01 00:00:01 1900-01-01 00:00:00 1900-01-01 00:00:01 1900-01-01 00:00:01 1900-01-01 00:00:00 1900-01-01 00:00:01 1900-01-01 00:00:01 1900-01-01 00:00:00 1900-01-01 00:00:02 1900-01-01 00:00:02 1900-01-01 00:00:00

This may simply be an issue with the incoming OSC messages coming from the other end.(An NGIMU)

nchollan avatar Jul 24 '18 18:07 nchollan

I am unsure about how the client on the other end is working but looking at that log it looks to me that these might be delays and not actual timestamps... Have you verified that the NGIMU put a timestamp in its message? Looking at your comment I am not sure where these come from sorry.

attwad avatar Jul 25 '18 20:07 attwad

According to NGIMU documentation they provide a ttag sent in accordance with the OSC protocol. Thank you so much for the help. Ill share my solution once I reach it.

nchollan avatar Jul 26 '18 13:07 nchollan

Hi,

I had the same issue as @nchollan (with an NGIMU as well). I managed to return the timestamp of the OSC messages by adding a needs_ttag option to the Handler object, and adding the ttag as an argument for the invoke function. I can share the solution here if you'd like to!

Hudsaul avatar Jun 24 '20 07:06 Hudsaul

I am having the same issue using an NGIMU. @Hudsaul it would be great if you could share your solution please!

dgregan avatar Aug 13 '20 15:08 dgregan

I also want to get the timestamp. I am looking for the function get_ttag() in this library, but I could not find it. Could you please tell me where get_ttag() is?

vatthaphon avatar Nov 29 '21 07:11 vatthaphon