Question

I have writen an objective-c POS that needs to interact with many ethernet devices like barcode scanner, fuel pump, cash drawer, etc. I know i'll probably have to write drivers in c++ for each device. The problem is I have no idea of how to write ethernet devices drivers. Is there anybody who can help me?

Btw, I haven't seen any code sample for ethernet drivers on the Apple dev site.

Thanks in advance!

Était-ce utile?

La solution

If the platform your working with is running iOS or MacOS, then it already has an Ethernet driver and a TCP/IP stack. What you probably need to write are modules/classes that communicate with the various devices using a socket API. These modules/classes are written at the application level, and are not OS device drivers.

To use sockets on iOS/MacOS, you can work with either the CFNetwork framework, or more directly with BSD sockets. There is lots of literature and examples on socket programming. There is not as much litterature on CFNetwork, but CFNetwork has the advantage of being easier to integrate with your app's run loops.

Check out this answer that lists resources for learning sockets network programming.


A third option would be to use the Boost.Asio library, which is "a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach". This documentation page shows several examples on how to use asio. You can use Objective-C++ (with *.mm files) to mix Objective-C with C++.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top