查看: 8414|回复: 9

PeerTalk, BeagleBone, and Raspberry Pi

[复制链接]
  • TA的每日心情
    奋斗
    2020-9-28 10:10
  • 签到天数: 1018 天

    连续签到: 1 天

    [LV.10]以坛为家III

    发表于 2013-5-14 09:24:19 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 xinxincaijq 于 2013-5-14 11:06 编辑

    翻译文章送铜板!

    欢迎广大热爱电子的网友对本E文进行翻译,将要翻译的原文和译文跟帖回复在本帖下,可以翻译一段或几段,如若能翻译全篇,更是欢迎!
    凡是参与翻译,并且质量尚可的网友,均可获得10~100铜板奖励!

    I came across an excellent bit of wizardry by Rasmus Andersson called PeerTalk. It’s a Objective-C library allowing you to communicate between your iPhone and your Mac over the USB dock cable using TCP sockets.
    译文 from@l廖天一阁主 我遇到一个相当不错的使用方案,这个是出自安德森的,被称作PeerTalk。他是一个基于Objective——c库来让你的苹果电话和电脑通过USB电缆使用TCP套接字进行通信。
      
    http://player.youku.com/player.php/sid/XNTU2NTcyNDA4/v.swf

    My immediate thought was that if this really only depended on having USB host mode capability at the far end, the same mechanism should be able to be used to talk to something like the BeagleBone, or the Raspberry Pi, not just your Mac. This would allow you connect your phone directly to the micro controller board and to drive hardware directly, a lot like the Redpark cable but bypassing Apple’s External Accessory framework.
    译文from@l廖天一阁主我立刻就想如果这真的只是取决于在远端的USB主机模式的能力大小,所以说同样的机制应该能用来和BeagleBone,或者Raspberry Pi,总之不仅仅是你的MAC。这就可以让你直接让你的手机和微控制器进行连接并且可以直接驱动外围硬件设备。这就非常像Redpark电缆但是又绕过了苹果的外部辅助架构。  
    img_0035.jpg

    So I started digging around inside the source code to see if it depended on anything that was going to be specific to OS X, it became apparent that PeerTalk was mostly some really nice socket code sitting on top of the USB Multiplex Daemon (usbmuxd). This bit of software is in charge of talking to your iPhone over USB and coordinating access to its services by other applications. Effectively this is what iTunes and Xcode use to talk to your phone when you plug it into your Mac’s USB port.

    译文from@l廖天一阁主于是,我开始到处深挖里面的源代码,看它是否依赖于任何东西,还是要具体到OS X,很明显,PeerTalk是非常好的套接字代码坐在了USB的多重守护进程(usbmuxd)的顶部。这个软件负责通过USB和你的iPhone进行对话并且协调由其他应用程序访问其服务。实际上这就是当你将它插入你的Mac的USB端口时iTunes和Xcode用他和你的手机进行对话。
      所以任何设备想要使用这种方法和iphone进行通信都要通过usbmuxd。幸运的是,对我来说已经有很多人解决了如何在LINUX下和电话通信,并且也有一个USBmuxd在Linux上运行了。


    So any device that wants to talk to the iPhone using this method needs usbmuxd. Fortunately  for me there are a number of people who have worked out how to talk to the iPhone from Linux, and there is a working usbmuxd for Linux.

    img_6064.jpg

    There are also As a few other dependencies which aren’t present on the stock Ångström Linux distribution on my BeagleBone, or even packages via opkg, building usbmuxd on my BeagleBone requires libusb and cmake. So before building usbmuxd, I had to build cmake, which meant resolving some problems with the stock compression libraries that shipped with Ångström.



    However several hours later after enough waiting around for software to build to convince me that before doing any serious development on the BeagleBone I really had to build an ARMv7 toolchain on my Mac to cross-compile things instead of building them directly on the board….

    img_0036.jpg

    …I managed to get a simple “hello” from my iPhone to the BeagleBone and then via screen to my Mac using port forwarding and that old stand by, telnet.



    While I was hacking away on getting this working, I wasn’t alone. David House was looking down some of the same back alleyways to get PeerTalk talking to his Raspberry Pi, and we batted the problem back and forth on Twitter while waiting for code to compile well into the night…



    While I was working on one end, David was working on the other, putting together a client on the Raspberry Pi sitting on top of usbmuxd that’d talk natively to the PeerTalk on iOS which he called peertalk-python. Since we had the source code of both ends, it wasn’t that hard. Just hard enough.



    If you want to replicate this on the BeagleBone, or the Raspberry Pi, you should first download and build the PeerTalk library, and then build and deploy the iOS and OSX example applications and get that up and running.



    Then connect up and boot your BeagleBone. You’ll need to power the board using a mains adapter as when you’re compiling things. It’s possible you’ll be drawing enough amperage that your computer will turn off the USB port to protect itself and as a result power down your BeagleBone. I had this happen to me a couple of times before I finally dug a mains adapter out of my office drawer. However since you’re powering the board from the mains you’ll also have to connect an Ethernet cable so that you can ssh root@beaglebone.local and log into the board over the network.



    1. Go ahead and login to your BeagleBone as root.
    2. Download, build and install libusb. Version 1.0.9 builds, links and installs okay.
    3. Download, build and install cmake, which you’ll need to buildusbmuxd later.You’ll need to grab the latest Git nightly checkout as older release versions don’t build, having problems with the stock libbz2compression on the BeagleBone.

    4. We also need libplist, however this is available as part of the package management system on Ångström Linux, so all you need to do to install this is type opkg install libplist-dev at the prompt.

    5. Download, build and install usbmuxd. Version 1.0.8 builds, links and installs okay, although you may beed to use ccmake and configure by hand, rather than using cmake, as it can’t seem to find the libusb include files that got installed into /usr/local.
    6. Create a usbmux user

    groupadd -r usbmux -g 114
    useradd -r -g usbmux -d / -s /sbin/nologin -c “usbmux user” -u 114 usbmux

    7. As the BeagleBoard doesn’t have syslog turned on by default, and you’ll need it for debugging, turn on syslogd from the relevant script in /etc/init.d.

    8. Run up the usbmux deamon, by typing usbmuxd -v -v at the prompt.
    9. Plug your iPhone into the (host side) USB on your BeagleBoard, you should see some debug scrolling by in /var/log/messages.

    10. Download David House’s peertalk-python and its dependances.

    11. On your iPhone start the PeerTalk client for iOS.

    12. Start the python client on the BeagleBone by typing python ./peertalk.py at the prompt.

    Type in a message at the prompt, and you should see something like this…

    img_0039.jpg
    From there it’s pretty trivial to build a “Hello World” example, just by hacking around with David’s code and toggling the heartbeat LED when the BeagleBone receives any messages.
    1. def run(self):
    2.         framestructure = struct.Struct("! I I I I")
    3.         ledOn ='echo 1 > /sys/class/leds/beaglebone::usr0/brightness'
    4.         ledOff ='echo 0 > /sys/class/leds/beaglebone::usr0/brightness'
    5.         i = 0
    6.         while self._running:
    7.             try:
    8.                 msg = self._psock.recv(16)
    9.                 if len(msg) > 0:
    10.                     frame = framestructure.unpack(msg)
    11.                     size = frame[3]
    12.                     msgdata = self._psock.recv(size)
    13.                     print "Received: %s" % msgdata
    14.                     if i == 0:
    15.                        os.system(ledOn)
    16.                        i = 1
    17.                     else:
    18.                        os.system(ledOff)
    19.                        i = 0
    20.             except:
    21.                 pass
    复制代码
    Which gets you to this point…
    http://player.youku.com/player.php/sid/XNTU2NTczMDQ4/v.swf
    Which is pretty much where I’ve reached right now. Next steps is a proper application on the iOS end of things with more generic control of the BeagleBone’s header pins, and a more flexible Python backend on the BeagleBone itself. David House also managed to get everything up and working on the Raspberry Pi.
    http://player.youku.com/player.php/sid/XNTU2NTcyNzE2/v.swf
    The only changes from the BeagleBone set up procedure is that you should grab libplist using apt-get rather than opkg, and since you won’t be logged in as root you should remember to sudo usbmuxd -v -v when you start the USB daemon. Apart from that, you should be good to go…



       
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2014-12-24 12:35
  • 签到天数: 26 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2013-5-14 10:08:20 | 显示全部楼层
    有道翻译,嘎嘎嘎。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2015-2-14 09:02
  • 签到天数: 656 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2013-5-14 10:08:44 | 显示全部楼层
    这个可以有
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2016-11-21 16:16
  • 签到天数: 130 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-5-14 10:11:19 | 显示全部楼层
    有道不行吗?
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2020-9-10 08:39
  • 签到天数: 125 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-5-14 10:13:03 | 显示全部楼层
      我遇到一个相当不错的使用方案,这个是出自安德森的,被称作PeerTalk。他是一个基于Objective——c库来让你的苹果电话和电脑通过USB电缆使用TCP套接字进行通信。
      我立刻就想如果这真的只是取决于在远端的USB主机模式的能力大小,所以说同样的机制应该能用来和BeagleBone,或者Raspberry Pi,总之不仅仅是你的MAC。这就可以让你直接让你的手机和微控制器进行连接并且可以直接驱动外围硬件设备。这就非常像Redpark电缆但是又绕过了苹果的外部辅助架构。

    点评

    你是第一个参与翻译的,而且翻译的不错,赞一个!!!  发表于 2013-5-14 10:28

    评分

    参与人数 1与非币 +10 收起 理由
    小菜儿 + 10 赞一个!

    查看全部评分

    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2015-2-14 09:02
  • 签到天数: 656 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2013-5-14 10:13:11 | 显示全部楼层
    有PeerTalk,BEAGLEBONE或者Raspberry Pi的朋友可以多参与
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2020-9-10 08:39
  • 签到天数: 125 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-5-14 10:14:00 | 显示全部楼层
    。。。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2020-9-10 08:39
  • 签到天数: 125 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-5-14 10:32:25 | 显示全部楼层
    我英文不好的。。。。要是日文的还好些。。嘿嘿 我觉得翻译的太差劲了,就不献丑了。就是为了捧场!!!!!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2020-9-10 08:39
  • 签到天数: 125 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-5-14 10:55:03 | 显示全部楼层
      于是,我开始到处深挖里面的源代码,看它是否依赖于任何东西,还是要具体到OS X,很明显,PeerTalk是非常好的套接字代码坐在了USB的多重守护进程(usbmuxd)的顶部。这个软件负责通过USB和你的iPhone进行对话并且协调由其他应用程序访问其服务。实际上这就是当你将它插入你的Mac的USB端口时iTunes和Xcode用他和你的手机进行对话。
      所以任何设备想要使用这种方法和iphone进行通信都要通过usbmuxd。幸运的是,对我来说已经有很多人解决了如何在LINUX下和电话通信,并且也有一个USBmuxd在Linux上运行了。
      

    评分

    参与人数 1与非币 +10 收起 理由
    小菜儿 + 10 赞一个!

    查看全部评分

    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2018-8-29 20:40
  • 签到天数: 1341 天

    连续签到: 1 天

    [LV.10]以坛为家III

    发表于 2013-5-14 12:22:26 | 显示全部楼层
    不错不错 这个奖励好
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /5 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-12-20 16:04 , Processed in 0.203262 second(s), 35 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.