Skip to content

Instantly share code, notes, and snippets.

@GOROman
Last active January 13, 2016 05:18
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save GOROman/7596186 to your computer and use it in GitHub Desktop.
PCからTHETAのシャッターを切る最小限のサンプルプログラム
#!ruby
#
# THETAのシャッターをPCから遠隔で切るだけの例 by GOROman
#
# 参考にしたページ
# http://mobilehackerz.jp/contents/Review/RICOH_THETA
require 'socket'
Init_Command_Request = 1
Cmd_Request = 6
OpenSession = 0x1002
InitiateCapture = 0x100E
# パケット送る
def send_to_theta( s, data )
s.write [ data.length + 4 ].pack("V") + data
end
# THETAへTCP接続
TCPSocket.open( '192.168.1.1', 15740 ) { |s|
# 初期化
send_to_theta( s, [ Init_Command_Request, "F"*32, 1 ].pack( "VH32V" ) )
# セッション開始
send_to_theta( s, [ Cmd_Request, 1, OpenSession, 0, 1 ].pack( "VVvV*" ) )
# 撮影
send_to_theta( s, [ Cmd_Request, 1, InitiateCapture, 0, 0, 0 ].pack( "VVvV*" ) )
}
@GOROman
Copy link
Author

GOROman commented Nov 23, 2013

THETA側はトランザクションIDは見てない模様。

@GOROman
Copy link
Author

GOROman commented Nov 23, 2013

GUIDは何でもいい模様。

@mhulse
Copy link

mhulse commented Aug 24, 2014

Thanks for this @GOROman! For anyone looking for a Python solution, check this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment