rsms / peertalk Goto Github PK
View Code? Open in Web Editor NEWiOS and Mac Cocoa library for communicating over USB
Home Page: https://rsms.me/peertalk/
License: MIT License
iOS and Mac Cocoa library for communicating over USB
Home Page: https://rsms.me/peertalk/
License: MIT License
when i send message fast, memory of iOS client become very high.
Peertalk is a very fantastic project! As there's still many old devices such as ipad2 and iphone4s. To make extremely good use of these old devices I decide to graft this project on ios8, which is completely jailbroken.
The building device I use is macos12.2 with xcode10.0, and the target device includes an iphone4s with iOS9.3.6 and an ipad2.1 with ios8.4.1. The building process is extremely smooth without removing or changing any codes in the project, and I get success in building and transferring the project on both iphone4s and ipad2. Unfortunately, the app can't work correctly on my devices.
When I turn on the debug modes, it shows like below:
iOS log informations(Peertalk iOS example):
objc[326]: Class PTUSBHub is implemented in both /private/var/containers/Bundle/Application/1F11F48D-B6F7-40D2-A102-5CD5D8EA3184/Peertalk iOS Example.app/Frameworks/Peertalk.framework/Peertalk and /var/containers/Bundle/Application/1F11F48D-B6F7-40D2-A102-5CD5D8EA3184/Peertalk iOS Example.app/Peertalk iOS Example. One of the two will be used. Which one is undefined.
objc[326]: Class PTUSBChannel is implemented in both /private/var/containers/Bundle/Application/1F11F48D-B6F7-40D2-A102-5CD5D8EA3184/Peertalk iOS Example.app/Frameworks/Peertalk.framework/Peertalk and /var/containers/Bundle/Application/1F11F48D-B6F7-40D2-A102-5CD5D8EA3184/Peertalk iOS Example.app/Peertalk iOS Example. One of the two will be used. Which one is undefined.
error in __connection_block_invoke_2: Connection interrupted
macOS log informations:
objc[92468]: Class PTUSBHub is implemented in both /Users/rainy/Library/Developer/Xcode/DerivedData/peertalk-drmhcxzanttrepgdctirorvfsnce/Build/Products/Debug/Peertalk.framework/Versions/A/Peertalk (0x100475138) and /Users/rainy/Library/Developer/Xcode/DerivedData/peertalk-drmhcxzanttrepgdctirorvfsnce/Build/Products/Debug/Peertalk macOS Example.app/Contents/MacOS/Peertalk macOS Example (0x10000d520). One of the two will be used. Which one is undefined.
objc[92468]: Class PTUSBChannel is implemented in both /Users/rainy/Library/Developer/Xcode/DerivedData/peertalk-drmhcxzanttrepgdctirorvfsnce/Build/Products/Debug/Peertalk.framework/Versions/A/Peertalk (0x100475160) and /Users/rainy/Library/Developer/Xcode/DerivedData/peertalk-drmhcxzanttrepgdctirorvfsnce/Build/Products/Debug/Peertalk macOS Example.app/Contents/MacOS/Peertalk macOS Example (0x10000d548). One of the two will be used. Which one is undefined.
(lldb)
it seems that iOS and macOS can't communicate well, but I can't find the problem where it locates in.
can anybody help me?
When an iPhone/iPad is plugged in, but the iOS app that communicates with the Mac app is not running, the enqueueConnectToUSBDevice
method is triggered every PTAppReconnectDelay
seconds until the connection is made. This delayed call seems to add ~100kb to used memory on every call, and is never released. This adds up over time, and slows down the Mac app.
I could reproduce this in the Peertalk Example app, in my own app, and also noticed it happening in Quartz Composer with Origami installed.
Console output:
10/30/15 12:46:51.705 PM com.apple.usbmuxd[49965]: HandleUSBMuxDictionary client 0x7fce19420800-Quartz Composer/NULL using library 151.1, running usbmuxd-364
10/30/15 12:46:51.706 PM com.apple.usbmuxd[49965]: MuxTCPInputSCE received RST for 0x1e-ef766571a2af13fc4d603d460e1943592582f130@0x41123000:2345->0x7fce19420130-Quartz Composer/NULL:40149: handleConnectResult: failure - 61
The line of code for reference : https://github.com/rsms/peertalk/blob/master/Peertalk%20Example/PTAppDelegate.m#L330
I tried using __block
to pass weak references of self
and other variables to the callback, but that did not help. If I remove this line it stops using memory, but, obviously, it also doesn't detect the app being launched if the device was already plugged in before launch.
Any ideas on how to avoid the memory usage?
Hi,
First of all very nice solution, thank you.
But I have one question.
Is it possible to detect connected Android device?
Hi @everyone,
someone know if it there's a way to adapt PeerTalk protocol communication (that is based on usbmuxd) in order to create a path for a communication between an iOS device and an Arduino UNO?
Thank's in advance.
Will it ever be able to send and receive in the iOS background? I've tried setting on some background modes and even a background identifier, but that does not seem to work.
Thanks in advance
I got error when i was running both app and my display was stuck with some time and the both app did got error after my display blinking.After that the sample project crash with the below method
Actually what you did with my systems.
Hi
Does peertalk OSX app rely on some Apple's core framework or it can be implemented in something else? I'd need to make a nodejs (or anything cross-platform) implementation so it'd work on windows but I'm not really sure what makes all of this work without a jailbroken phone.
Best regards,
PB
It's a very interesting piece of software, but the fact that the last commit was made in December 2020 worries me a bit. Is this actively maintained? :)
Can I send/receive data via a USB OTG cable between my ios device and Arduino with this platform?
When I connect a memory device(Flash) via OTG to my iOS device I can access all files
It would be cool if you could add support for Carthage.
https://github.com/Carthage/Carthage#supporting-carthage-for-your-framework
I just spent several hours debugging this - it doesn't seem to be mentioned anywhere. Am I missing something?
When i try to use PTChannel connect the second device to a new port, get the error like this:
Error Domain=PTUSBHubError Code=3 "connection refused" UserInfo={NSLocalizedDescription=connection refused
Hi,
great work.
Is there way to connect two ios devices to OSX and recognize where is first and where is second, I need to make app bundle source synchronization between two ios devices through USB connected to OSX.
I need to sync, video and images not loaded in memory, as a files.
is there possible?
thank you very much.
This is rather a RFC than an actual issue.
I would be happy to connect an iPad as a additional screen to my Linux system via a wired connection. One application that does it for Mac OS is the awesome Duett Display app you mention in the readme and which lead me here [1].
Would it be possible to use this library from a Linux system now that at least parts of libcentraldispatch are getting ported [2]?
Or would I be better off reimplementing the functionality utilizing usbmuxd [3] to achieve the same goals?
Thank you for your time! π
When pulling PeerTalk through CocoaPods it is not pulling the latest codebase. Its actually pulling an old commit since version 0.0.1 points to an old commit.
Would it be possible to push a new podspec to cocoapods master repo for version 0.0.2 and tag the master branch with tag 0.0.2?
I can do a PR for the podspec if you will
Hi, I'm just wondering if it's is possible to send data via peertalk to macos but instead of using objective-c on the macos side to use python. I'm doing some realtime signal processing and it's easier for me to prototype algorithm using python and opencv. I bet there is currently no python binding but would like to know if it's teoretically possible to intercept peertalk usb data via e.g. pyserial. Any tips and ideas how to best approach this?
Per step 2 of your getting started steps, running Peertalk example target caused 6 Semantic issue error, e.g,
peertalk/peertalk/PTUSBHub.m:485:5: Objc_precise_lifetime only applies to retainable types; type here is 'dispatch_data_t' (aka 'struct dispatch_data_s *')
peertalk/peertalk/PTUSBHub.m:515:7: Objc_precise_lifetime only applies to retainable types; type here is 'dispatch_data_t' (aka 'struct dispatch_data_s *')
peertalk/peertalk/PTProtocol.m:216:7: Objc_precise_lifetime only applies to retainable types; type here is 'dispatch_data_t' (aka 'struct dispatch_data_s *')
Actually step 1 running unit tests for peertalk target also failed
peertalk/peertalk/PTProtocol.m:216:7: Objc_precise_lifetime only applies to retainable types; type here is 'dispatch_data_t' (aka 'struct dispatch_data_s *')
I am trying to make an HDMI -> iPad application.
Ideally, the configuration would go as follows:
HDMI -> converter -> USB-C -> iPad -> decode HDMI data into video
Preferably, I'd only need to use one-way communication - I don't care for the iPad to respond to the HDMI provider (unless that's necessary). Is it possible to instead of PeerTalk... just, PeerListen?
why PTUSBHub hard code api that connectToDevice in main queue?
- (void)connectToDevice:(NSNumber*)deviceID port:(int)port onStart:(void(^)(NSError*, dispatch_io_t))onStart onEnd:(void(^)(NSError*))onEnd {
PTUSBChannel *channel = [PTUSBChannel new];
NSError *error = nil;
//open main queue ?
if (![channel openOnQueue:dispatch_get_main_queue() error:&error onEnd:onEnd]) {
onStart(error, nil);
return;
}
// ....
}
Example for iOS works ok, but when I'm trying to use libs in my own project (swift version with objective-c++ .mm classes bridges) I get next error:
Cannot initialize a variable of type 'PTExampleTextFrame *' (aka '_PTExampleTextFrame *') with an rvalue of type 'void *'
in this function (Peertalk Example) PTExampleProtocol.h
also this header file for Mac target/project, so does why iOS target/project reference to it?
static dispatch_data_t PTExampleTextDispatchDataWithString(NSString *message) {
// Use a custom struct
const char *utf8text = [message cStringUsingEncoding:NSUTF8StringEncoding];
size_t length = strlen(utf8text);
//CFAllocatorAllocate(nil, 1 + length, 0);
PTExampleTextFrame *textFrame = CFAllocatorAllocate(nil, sizeof(PTExampleTextFrame) + length, 0);
memcpy(textFrame->utf8text, utf8text, length); // Copy bytes to utf8text array
textFrame->length = htonl(length); // Convert integer to network byte order
// Wrap the textFrame in a dispatch data object
return dispatch_data_create((const void*)textFrame, sizeof(PTExampleTextFrame)+length, nil, ^{
CFAllocatorDeallocate(nil, textFrame);
});
I want to send some msgs on all connected usb devices. Here this code works for only single connected device. is there any way to connect to more than one device at a time. Thanks for the help in advance.
I can't initialize PTUsbHub
PTUSBHub failed to initialize: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
Is there a way to open a NSStream over the connection? This would be much apriechieted
We're getting crash dumps from our OS X app pointing to an assertion being triggered in PTUSBHub.m line 66:
#0. Crashed: com.apple.libdispatch-io.opq
0 libsystem_kernel.dylib 0x7fff8d4b5286 __pthread_kill + 10
1 libsystem_pthread.dylib 0x7fff8c6379f9 pthread_kill + 90
2 libsystem_c.dylib 0x7fff93a8f9ab abort + 129
3 libsystem_c.dylib 0x7fff93a57a91 __assert_rtn + 319
4 Application 0x109abf3c8 usbmux_packet_alloc (PTUSBHub.m:66)
5 libdispatch.dylib 0x7fff947f8e2b ___dispatch_operation_deliver_data_block_invoke + 118
6 libdispatch.dylib 0x7fff947e0700 _dispatch_call_block_and_release + 12
7 libdispatch.dylib 0x7fff947dce73 _dispatch_client_callout + 8
8 libdispatch.dylib 0x7fff947e05cd _dispatch_queue_drain + 1100
9 libdispatch.dylib 0x7fff947e0030 _dispatch_queue_invoke + 202
10 libdispatch.dylib 0x7fff947ed5aa _dispatch_main_queue_callback_4CF + 416
11 CoreFoundation 0x7fff8a5fd3f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
12 CoreFoundation 0x7fff8a5b868f __CFRunLoopRun + 2159
13 CoreFoundation 0x7fff8a5b7bd8 CFRunLoopRunSpecific + 296
14 HIToolbox 0x7fff8968356f RunCurrentEventLoopInMode + 235
15 HIToolbox 0x7fff896832ea ReceiveNextEventCommon + 431
16 HIToolbox 0x7fff8968312b _BlockUntilNextEventMatchingListInModeWithFilter + 71
17 AppKit 0x7fff872698ab _DPSNextEvent + 978
18 AppKit 0x7fff87268e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
19 AppKit 0x7fff8725eaf3 -[NSApplication run] + 594
20 AppKit 0x7fff871db244 NSApplicationMain + 1832
21 Application 0x109a935d4 start + 52
We poll the USB port repeatedly waiting for a device with our client app to connect. The crazy thing about that is the assert being triggered should be:
static usbmux_packet_t *usbmux_packet_alloc(CFIndex payloadSize) {
assert(payloadSize <= UINT32_MAX); // protocol limitation
uint32_t payloadLength = (uint32_t)payloadSize;
but the stack shows this coming from the dispatch_io_read
in scheduleReadPacketWithCallback
(PTUSBHub.m:494), which uses a uint32_t
parameter, thus making it (theoretically) impossible to overflow UINT32_MAX
:
// Allocate a new usbmux_packet_t for the expected size
uint32_t payloadLength = upacket_len - sizeof(usbmux_packet_t);
usbmux_packet_t *upacket = usbmux_packet_alloc(payloadLength);
Any ideas? Maybe stack corruption in the previous memcpy
(should be protected by the assertion, so...)?
Can I use Peertalk to send message between iPhone and iPad via USB connect ?
These errors were fixed in 0.0.2 but it's not available in Cocoapods official repo.
When I try to submit a Mac app that uses peertalk, it sends me an error and says that I have to enable the sandbox. However, I get the Operation Not Permitted error because peertalk is no longer able to write to the device.
I tried making an exception according to another user on this stack overflow post, but it does not work.
How can I either disable sandbox and still use peertalk, or enable an exception in sandbox for peertalk? Thanks!
After installing peertalk via Cocoapods (and not changing anything else about my project), I get the following linking error:
4 duplicate symbols for architecture x86_64
I've tried every solution I can find online, so I was hoping it was an issue with the project. Can anyone reproduce my error / offer a solution?
I was using Swift, but I ended up recreating my project as Objective-C and that didn't fix it.
The Cocoapods version available right now is 0.0.1. I noticed in #32 that version 0.0.1 is throwing linking errors. Seeing as there is a Podfile in the repository, it looks like this is meant to be officially on Cocoapods, however the version available is not what is in the Podfile here.
I try to find way to launch peertalk ios with linux server backend.
I try to understand, is there any way to replace peertalk mac os with usbmuxd ( libimobiledevice )
Can I ask for some hint?
I setup a http-server on Macbook, then perform "iproxy 8080 8080", finally I need to visit the website on an iPhone, can I directly enter 127.0.0.1:8080 safari it? or write an APP, which wrapped peertalk.
best wish for you ,i am not good at english.:-D
i found peertalk memory leaks happen when receive message and answers, and may crash.
Maybe at "- (void)readFrameOverChannel:(dispatch_io_t)channel callback:(void(^)(NSError *error, uint32_t frameType, uint32_t frameTag, uint32_t payloadSize))callback" , but i can not ensure it ~
please help me to check and solve it ~
english is not good, so sorryγ
Why is the example app trying to enqueueConnectToLocalIPv4Port ?
as everything is working without it
// Start trying to connect to local IPv4 port (defined in PTExampleProtocol.h)
[self enqueueConnectToLocalIPv4Port];
and iam also wondering a bit why it works, as the client iOS app listnes on IPV4 port
[channel listenOnPort:PTExampleProtocolIPv4PortNumber IPv4Address:INADDR_LOOPBACK callback:^
By using your library I faced up with slow transferring issue. My setup is using serial port for grabbing incoming data and translate them via usb to iOS. My serial is usually has 115200 baud rate (it's about ~ 230kbits/s) and I see the big differences with displaying big data in uitextview which were received from serial port and from usb (using peertalk). The data from serial port is displaying almost immediately.
I want to know if it's possible to connect the peertalk iOS app with Ubuntu OS, without using the MacOS app.
My app suite connects Windows/Mac with iOS and I'm trying to use unified communication protocol. Apparently I cannot use PeerTalk directly on Windows. So I'd love to strip off everything but the usbmuxb
service features of PeerTalk codebase, just to ensure that a TCP socket server running on iOS can receive data through USB.
Now the question is: Can I achieve my goal by simply using the PTUsbHub
class alone?
Hello, first of all, thank you for an awesome library. But I can't find even "Getting Started" guide or simple code examples(without complete demo app). Could you please add at least that? Thank you!
Hi, I'm a software engineer at AT&T.
I used the peertalk library from my UITest (based on XCTest) on AppleTV.
This UITest was developed using Swift with a bridge header to the peertalk library.
I developed the UITest according to the iOS example.
On the Mac I simply run the example GUI.
I successfully sent messages from AppleTV to Mac, but the messages from the Mac to the AppleTV
don't arrive.
Details: The delegate's method ioFrameChannel-didReceiveFramOfType is not called when I send
a message from the Mac GUI.
I wonder if it is possible to work with peertalk on AppleTV too.
Thanks,
Eli
[EMAIL REDACTED]
Case:
My decision:
I change code in PTChannel.m from
" NSError *err = error == 0 ? _endError : [[NSError alloc] initWithDomain:NSPOSIXErrorDomain code:error userInfo:nil];
"
to
"
NSError *err = error == 0 ? channel->_endError : [[NSError alloc] initWithDomain:NSPOSIXErrorDomain code:error userInfo:nil];
"
And in callback i have correct error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.