How to implement CAN Bus on STM32F042k6 without Std Lib and CubeMX - stm32

I am trying since a couple of days to implement a CAN Bus communication for my above mentioned board without success. I wish to do this using the Registers only. Can someone give some hints on how I should proceed? or a link?. Thanks in advance.

Why don't you use the Std Lib as a starting point?
The library includes all functions and registers you need. You must simply go through one of the examples and "copy" the direct register accesses to your project.
(And perhaps you also want to use some of their defines for the bit definitions)

Related

Codesys CAA_File and SysFile library difference

What is the difference between Codesys CAA_File lib and SysFile lib? When to use CAA_File instead of SysFile?
SysFile
Makes a direct call to the CODESYS Runtime component. This API is used by the CODESYS Runtime to download program / open programs ETC.
Its very optimized in the sense that every function does a very well define task.
All the functions here a very low level.
CAA_File,
Uses a standardized API (defined by the CAA Workgroup), focused on the IEC Programmer needs.
It takes a more high level approach, giving you extra functionality that will not find in SysFile (but you can implement it yourself).
At the end, CAA_File ends up calling SysFile.
Depending on your target, you might not be able to use SysFile. Linux / Windows devices usually come with all the components.
I would use SysFile only if I wanted to create my own library or if I wanted to have a very efficient process, or if I didn't require any special protection / features.
If I wanted to keep things simple I would use CAA_File.
Source: I have integrated CODESYS Runtime into custom embedded platforms.

porting java code to contiki-os

i am using contiki-os to simulate some motes which would have semantic capabilities. As the contiki-os (erbium) is written in C but our semantic libraries are written in java.
can anyone here guide me if it is possible to exploit these libraries in erbium or contiki-os. or i have to rewrite everything from scratch ?
update
just a minor update to the question. is it possible to use java code on the cooja simulator?
Cooja is indeed written in Java.
You can extend or modify Cooja if you need.
You can find out more about Cooja on the Contiki wiki as well as in numerous papres by Fredrik Österlind. Perhaps you should also take a look at Fredrik's PhD thesis "Improving Low-Power Wireless Protocols with Timing-Accurate Simulation", which is mostly about Cooja.
You might be able to use something like this:
http://www.codemesh.com/products/junction/
It appears to have a code generator that takes a java bytecode and create C code from it... but it might also need a runtime library that's platform specific.
With all that in mind, I don't think you will be successful. Most of the platforms are nearly out of space and/or flash by the time you are working with Erbuim; I doubt you'll have resources to process java code somehow.
And if you did get some success from this approach it would probably take a lot of time and effort to do so. With that time and effort you probably could have written the C code to do what you need instead.

SoftPhone and linux

We are thinking about writing a softphone app. It would basically be a component of a system that has calls queued up from a database. It would interface with a LINUX server which has Asterisk installed.
My first question is
Whether we should write the softphone at all or just buy one?
Secondly, if we do,
what base libraries should be use?
I see SIP Sorcery on CodePlex. More than anything, I am looking for a sense of direction here. Any comments or recommendations would be appreciated.
The answer would depend on the capabilities you have in your team and the place you see your core value and the essence of the service you provide.
In most cases, I'd guess that you don't really care about SIP or doing anything fancy with it that require access to its low level. In such a case, I'd recommend getting a ready-made softphone - either a commercial one or an open source one. I'd go for a commercial one, as it will give you the peace of mind as to its stability and assistance with bug fixing and stuff.
To directly answer your question, one of the many open source softphones are likely to fit your needs, and allow slight modifications as needed. Under most open source licenses there is no obligation to distribute your code as long as you only use it internally (do not distribute the binary.)
Trying to guess what you are trying to do, it sounds like a call center like scenario, so one of the many call queue implementations out there might fit your needs.
I had to write an own softphone and I found a great guide how to achieve it. In the guide there are 10 steps provided for having an own softphone (voip-sip-sdk.com on page 272)
I found it useful and maybe you will find it as well.

Communication between applications written in different languages

I am looking at linking a few applications together (all written in different languages like C#, C++, Python) and I am not sure how to go about it.
What I mean by linking? The system I am working on consists of small programs each responsible for a particular processing task. I need to be able to transfer a data set from one application to another easily (the data set in question is not huge, probably a few megabytes) and I also need some form of way to control the current state of the operation (This is where a client-server model rings a bell)
It seems like sockets or maybe SOAP would be a universal solution but just wanted to get some opinions as to what people think about this subject.
Comments/suggestions will be appreciated, thanks!
I personally take a liking towards ØMQ. It's a library that has a familiar BSD-sockets-like interface for passing messages, but you'll find it implements interesting patterns for distributing tasks.
It sounds like you want to arrange several processes in a pipeline. ØMQ allows you to do that using push and poll sockets. (And afterwards, you'll find it's even possible to scale up across multiple processes and machines with little effort.) Take a look at the guide to get started, and the zmq_socket(3) manpage specifically for how push and pull works.
Bindings are available for all the languages you mention.
As for the contents of the message, ØMQ doesn't concern itself with that, they are just blocks of raw data. You can use any format that suits you, such as JSON, or perhaps Protocol Buffers.
What I'm not sure about is the ‘controlling state’ you mention. Are you interested in, for example, cancelling a job halfway through?
For C# to C# you can use Windows Communication Foundation. You may be able to use it with Python and C++ as well.
You may also want to checkout named pipes.
I would think about moving to a model where you eliminate the issue by having centralized data that all of the applications look at. Keep "one source of the truth" so to speak.
Most outside software has trouble linking against C++ code, due to the name-mangling algorithm it uses for its symbols. For that reason, when interfacing with programs written in other languages, it is often best to declare wrappers to things as extern "C" or inside an extern "C" { block.
I need to be able to transfer a data set from one application to another easily (the data set in question is not huge, probably a few megabytes)
Use the file system.
and I also need some form of way to control the current state of the operation
Again, use the file system. A "current_state.json" file with a JSON serialized object is perfect for multiple languages to work with.
It seems like sockets or maybe SOAP would be a universal solution.
Perhaps. But it's overkill for this kind of thing. Your OS already has all the facilities you need. Just use the file system. It's very simple and very reliable.
There are many ways to do interprocess communication. As you said, sockets may be a universal solution. SOAP, i think, is somewhat an overkill. You may also use mailslots. I wrote C++ application using it a couple of years ago. Named pipes could be also a solution, but if you are coding on Windows, it may be difficult.
In my opinion:
Sockets
Mailslots
Are the best candidates.

How do you define an interface, knowing that it should be immutable once published?

Anyone who develops knows that code is a living thing, so how do you go about defining a "complete" interface when considerable functionality may not have been recognised before the interface is published?
Test it a lot. I've never encountered a panacea for this particular problem - there are different strategies depending on the particular needs of the consumers and the goals of the project - for example, are you Microsoft shipping the ASP.NET MVC framework, or are you building an internal LoB application? But distilled to its simplest, you can never go wrong by testing.
By testing, I mean using the interface to implement functionality. You are testing the contract to see if it can fulfill the needs. Come up with as many different possible uses for the interface you can think of, and implement them as far as you can go. Whiteboard the rest, and it should become clear what's missing. I'd say for a given "missing member", if you don't hit it within 3-5 iterations, you probably won't need it.
Version Numbers.
Define a "Complete Interface". Call it version 1.0.
Fix the problems. Call it version 2.0.
They're separate. They overlap in functionality, but they're separate.
Yes, you increase the effort to support both. That is, until you deprecate 1.0, and -- eventually -- stop support.
Just make you best reasonable guess of the future, and if you will need more create second version of your interface.
You cannot do it in a one-shot release. You need feedback.
What you can do is first make a clean interface that provide all the functionalities your library should provide; then expose it to your user base for real-world usage; then use the feedbacks as guide to update your interface -without adding features other than helper function/classes- until it starts to be stable on the interface.
You cannot rely only on experience/good-practice. It really helps but it's never enough. You simply need feedback.
Make sure the interface, or the interface technology (such as RPC, COM, CORBA, etc), has a well-defined mechanism for upgrades and enhanced interfaces.
For example, Microsoft frequently has MyInterface, followed by MyInterfaceEx, followed by MyInterfaceEx2, etc, etc.
Other systems have a means to query and negotiate for different versions of the interface (see DirectX, for one).