VB.net and GPIO [closed] - vb.net

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I need to open a cash drawer connected to a computer's RJ-11 Port. The manual said about the RJ11 connector case open: GPIO 63 ADD A25H(bit3)
How can I access to that GPIO from VB.Net? Anybody has an example?

Using Google I figured out that you are probably using a Biostar embedded PC motherboard
Manual
and the table you are referencing is :
This would seem to indicate that the value you are talking about is a STATUS pin - an input, not an output. The cash drawer would indicate to the PC the state of the drawer (open or closed) using this line. You would read this bit, not write to it, to learn the status of the drawer.
The GPIO is just memory mapped I/O. You would need to use a low level memory read at memory address 0xA25 to retrieve this word. Presumably writing to the CONTROL pins would cause the drawer to open. Without a better manual for your device it is difficult to say.
I don't think .NET provides any means to write to memory mapped IO but you may be able to do it by importing system .dll functions with code like this :
Converting Visual Basic parallel port app using inpout32.dll in to Delphi
but replacing the Parallel Port address with the ones you are interested in -- ie:
PortAddress = &HA25 ' etc
I'm not sure if the above DLL will let you specify other port addresses, it may not even be possible in modern windows to write to those ports directly (for system security reasons). Typically you would have to resort to starting from the Windows Driver Development Kit - this is not always a practical approach. It would be altogether better to see if your hardware manufacturer provides drivers already which you can import.

Related

What Kind of Prerequisite knowledge do I need to have to do TCP/IP Socket Programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I work in IT and I am learning about network security administration. I want to learn how to use any TCP/IP socket API to design and implement basic client/server applications. Do I need to know an object oriented programming language or are there already a wide variety of pre-made methods/functions for TCP/IP programming?
You need to have a solid understanding of stream IO, much like file IO. Once things are set up, it's effectively exactly like stream IO for many use cases. This includes the concept of stream operations, as well as proper error handling of the system calls.
You will need to understand text or binary protocols, and notably when to STOP reading. For some protocols, the stream remains open from event to event, but if you read beyond the end of a data packet, the other end of the socket may not be sending you anything, and your code will block, and this is likely not what you want. Being able to note when you should stop reading is very important. Some protocols use a marker, other use a length sent previously. This is a common cause of problems for beginning network programmers.
For binary protocols you will need to understand the byte arrangement of numbers, notably integers. Specifically big-endian vs little-endian vs "network order". Will also need to understand how to build larger constructs from bytes (again, notably, integers from bytes). If you do this improperly, your numbers will be quite wrong.
For a client, this is pretty much all you need. Once you create the socket, you will perform stream operations upon the resulting socket, sending and receiving bytes and blocks of information. When you are done, you will close the socket. Unless the protocol specifies, you should not rely on the server to close its socket to indicate to you that it is done. Make sure you clean up your resources on exiting.
If you wish to create a server and process more than one request at a time, you will need knowledge of threading, forking, or asynchronous IO in order to handle the multiple requests simultaneously. After that it becomes much like the client side, save for the initial creation of the listening socket is a little different.
There are certainly nuances and intricacies to network programming, but for the your basic connectivity, much of this can be ignored.
The scripting languages, Java, and .NET make network programming much, much easier than C. C exposes the raw sockets and leaves all of the detail, yet routine, operations to you. You will very likely have much more success starting out with a scripting language. I can not speak to any C or C++ libraries that make network programming easier. I'm sure they exist, I can not cite any.
You will also need patience to deal with the initial frustration, a sense of HURRAH! when it finally works, and a comfy chair to sit back in at the end when you go "Gee, now that wasn't so bad, this is pretty neat" and then peacefully reflect on what's next.
Finally, as I always suggest, do not CUT and PASTE sample code. Whatever you may find, type it in and try to understand each line as you type it in. You will have a much better grasp of how this works than if you just download something and watch it run.

Advantages and Disadvantages of Apache vs. Your own server? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have been working on my own ssl based multi process multi file descriptor threaded server for a few weeks now, needless to say it can handle a good amount of punishment. I am writing it in C++ in an object oriented manner and it is nearly finished with signal handling (atomic access included) and exception / errno.h handled.
The goal is to use the server to make multi-player applications and games for Android/iOS. I am actually very close to the completion, but it recently occurred to me that I can just use Apache to accomplish that.
I tried doing some research but couldn't find anything so perhaps someone can help me decide weather I should finish my server and use that or use apache or whatever. What are the advantages and disadvantages of apache vs your own server?
Thank you to those who are willing to participate in this discussion!
We would need more details about what you intend to accomplish but I would go with Apache in any case if it matches your needs:
it is battle tested for all kind of cases and loads
you can benefit from all the available modules (see http://httpd.apache.org/docs/2.0/mod/)
you can benefit from regular security patches
you don't have to maintain it yourself!
Hope this helps!
You can always write your own software even when perfectly well-proven alternatives exists, but you should be conscious about what are your reasons for doing so, and what are the costs.
For instance, your reasons could be:
Existing software too slow/high latency/difficult to synchronize
Existing software not extensible for my purpose
Your needs don't overlap with the architecture imposed by the software - for instance if you need a P2P network, then a client/server-based HTTP protocol is not your best
You just want to have fun exploring low-level protocols
I believe none of the above except possibly the last of these apply to your case, but you have not provided much details, so my apologies if I am wrong.
The costs could be:
Your architecture might get muddled - for instance you can fall into the trap of having your server being too busy calculating if a gunshot hits the enemy, when 10 clients are trying to initiate a TCP connection, or a buffer overflow in your persistent storage routine takes down the whole server
You spend time on lower level stuff when you should dealing with your game engine
Security is hard to get right, it takes many man-years of intrusion testing and formal proofs (even if you are using openSSL)
Making your own protocol means making your own bugs
Your own protocol means you have to make your own debuggers (for instance you can't test using curl or trace using HTTP proxies)
You have to solve many of the issues that have already been solved for the existing solution. For instance caching, authentication, redirection, logging, multi-node scaling, resource allocation, proxies
For your own stuff you can only ask yourself for help

USB Clear Endpoint Feature [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I am developing CDC driver for USB device and I stumble on some problem.
The driver I am using on windows side uses Clear endpoint Feature as some kind of flish mechanism or to get data right. That causes me a lot of trobule because I cant get it working. I think data toggle don't agree and I am missing some important data transfer, even not getting associated interrupt with that endpoing because of bad clear data toggle.
I reset data toggle to 0 at set interface and clear feature, as pointed out in USB standard.
Is there more situation when I should do this? Or is there easy way of error handling invalid data toggle.
Thanks for anwsering. I have got usb analyzer, but I dosen't do me any good now. From what I can managed to gather and I think is happening. I set datatoggle bit in hardvare after Clear feature (as it should be done) for coresponding endpoint. Send some data, It is recived on PC. I know this form USB analyzer and I traced my Vcom driver with port monitor.
Then I wait for some data as everything is configured (device enumerated and so on), the initial question is anwsered but the next one is not, after clear endpoint fature the PC side is asking the question again. This should trigger UBS interrupt for coresponding endpoint but it isint happening, again after some time there is clear endpoint feature and the same package, and it's get responded this time and again there is silence on the comunication protocol. I counted the requested tranfer versus missing interrupts and the ratio is exactly 2:1 so i think data toggling is set wrong by half of the time, but how can this be happening if i set data toggle bit every time I get clear endpoint feature.
I hope I stated the problem clearly, for the harvare side I think the only rvelant thing is the bit I am setting. It states "Write a 1 to this bit to reset the endpoint data toggle to 0."
Ok i think(hopefully) I solved the Clear endpoint fature, other errors were caused by other things, and cumulative problem was hard to catch.
Ok I fixed the issue some time ago, now I don't even remeber what was the cause but as ususally is - it was something else. Everyone who tied to anwser thanks.
Be aware that on some versions of usbser.sys, Windows does not correctly flush the pipe after a transfer of an exact multiple of 64 bytes. I'm not exactly clear from your question whether this is the behaviour you are seeing, but a USB analyser should help you determine if this is the case. If you are using XP SP2, upgrade to SP3.
I suggest to use usb snoopy (software usb analyzer) in order to understand what are you doing wrong. If you have any budget you better got hardware usb analyzer such us Lecroy or Ellisys. Or get a commercial CDC driver there is plenty available just google for cdc driver.
Your problem description is very general and can be addressed directly.

What was the most advanced stuff you did with compact framework [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
At work I use mostly the .NET Compact Framework 3.5 for developing applications that run on smart devices. Our devices are not phones or handhelds - they are measurement instruments which you get with a whole punch of features. Our application is pretty advanced - we are even using a N-Layer architecture, a self-made GUI framework and even dependency injection (we built our own as the ones other there are not lightweight enough).
So what's the most advanced things you did with the compact framework?
What's currently missing (for example a mocking framework, as there is no Reflection.Emit on compact framework)?
How are you developing your applications? Are you deploying your application every time to the device. In our case this is very slow, as the solution consists of 30 projects so we have a Win32 Version which runs on the PC.
We've done a plant-floor monitoring system that acts as a data server and a web server collecting data from PLCs and creating dynamic web-based reports all in the CF. We've created a peer-to-peer notification and file sharing system. We've done vehicle tracking and dispatching systems. We've done smart-farming applications that monitor loads of data from a tractor and couple that with location and previous year data, plus quite a few others. So I guess you could say de've written several highly-complex things using the CF.
There are lots of "missing" pieces, but most can be worked around. The most obvious missing piece that can't be worked around is the lack of EE Hosting. Reflection pieces for mocking would be nice, but we can live without - it just makes test more of a bear. The lack of Hosting makes several things simply impossible.
As for deployment, it's all about configuration. The Smart Device Framework itself, when coupled with all of the unit test stuff, is something like 45 projects. Deploying isn't bad as it only recompiled and deploys changes, and I often adjust the configuration of test applications to not deploy all projects, but only the main one. That should auto-deploy all references (eliminating the double-deploys you're probably getting). Also having all projects output to one common directory and setting "Copy Local" to false improves things quite a bit too.
One of the most useful things we do with our .net cf application is work hard to make sure that they can be re-targeted to the full framework. This means you have a second desktop project or a unit test that actually runs your entire application on the desktop. There is a bit of work to do if you are using device specific functionality via pinvokes or device only APIs, but the effort usually pays off because:
You can quickly run/debug your application without having to wait for an emulator or device to spin up
You are forced to architect your code in a way that device specific functionality can be mocked and tested
In many cases you are part way to having a desktop version of your application as well as the device version
It probably goes without saying that in the end, testing will need to be done specifically on the device, but during development and the quick code/debug cycles it is really nice to not wait on the emulator. I remember Daniel Moth posting something about how to actually create a device deployment target that is your desktop computer to achieve this same effect. Maybe someone else can find a link?
I have done Win CE app for industrial PDAs for route sales from pre-loaded inventory and clients list. It gets GPS coordinates, uses scanner to collect data, transmits data over GPRS/EDGE of sales made in the device. The app also prints a receipt (linked to protable printer ober BT).
I wrote an app that monitors the statistics on my self-made blog by interfacing with a WebService.
I have developed a multi-language dictionary. Using one code base on Windows, PDA and via MONO on unix and MAC.
Basically the application is complicated because we use multiple databases that are large. We were able to tweak the data access performance and lookups on large tables are almost instantaenous.
Small devices are not very powerful, but if you design for the way they work you can get good performance out of them.
I made an app to collect measures of any magnitude (for weather), using an n tier app, with MVC and using db4o as a database... Pretty impresive

Is there a good description of the "system call" mechanism used in OSes? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am looking for a good primer or technical description of the System Call mechanism that is used by operating systems to transition from user space to the kernel to invoke functions such as "open", "read", "write", etc...
Is there anything other than the Wikipedia entry?
Websites, pdfs, books, source code, all are welcome :)
The exact method depends on the processor architecture and what operations it defines for transferring to kernel mode. One approach, and the traditional one on x86, was to use a software interrupt. It turns out this wasn't very fast for the general case so later, Intel added SYSCALL and AMD added SYSENTER. Windows XP and later choose an appropriate system call technique for the platform, at boot time.
You could choose to use specific software interrupt numbers for specific functions, but generally the processor doesn't have enough interrupts to cover all the system functions, so it's necessary to make one of the registers contain the function number required. If you're doing that anyway, it's not much of a hardship to only use the one system call function.
Windows CE, before version 6.0, uses a side-by-side process virtual address model that actually allows processes to call into each other directly. The page protections are set up so that when this is done, an access violation fault occurs: the kernel gets control, fixes up the process address space (moving the called process into slot 0), fixes up slot-0-based arguments to point to the calling process, and returns to user mode. Because the return address is in another process, when the function call returns, the reverse process occurs. Unfortunately this model only allows very small virtual address spaces for each process (32MB) and a low number of processes (32), so Windows CE 6.0 reverts to a more traditional system call model.
Well for source code, there are plenty of open source kernels to dive into.
As for books, Robert Love's book on the Linux kernel is very informative.
You may want to have a look at the minix kernel. It's open source, designed to be simple, and is used in a lot of Uni-level OS courses. Have a dig around in /usr/src/kernel/proc.c especially the sys_call function and surrounding functionality. Keep in mind that minix is a microkernel, so some things may be subtlety different to what you are used to.
If you want to purchase a book that is extremely useful for *nix programming. I would recommend "Advanced Programming in the UNIX Environment" by Stevens and Rago.
It has in depth explanations, and code examples.
For a good explanation of system calls in Linux, look at the sample device drivers in Linux Device Drivers.
It's architecture dependent, and requires an understanding of computer architecture. Tanenbaum's "Structured Computer Organisation" has a good summary of the basics of a system call. For more, read any textbook on operating system design.