Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have been assigned a project in my lab to implement CAN protocol on ARM 7.
I looked for some tutorials and sample code, but all looks so much complex that I think I should get some help on the coding part. Can anybody explain me the basic transmitter and receiver coding on any ARM board?
The sender code is the following. I have used question marks where I don't understand the full meaning of an expression.
#include <lpc23xx.h>
#include "type.h
#include "can.h"
#include <LPC23xx.H>
CAN_MSG MsgBuf_RX1,MsgBuf_RX2; // TX and RX Buffers for CAN message
volatile DWORD CAN1RxDone, CAN2RxDone;
int main(void)
{
DWORD tempbuf1,tempbuf2;
int current;
FIO2DIR=0x000000FF;
CAN_Init(BITRATE100K28_8MHZ);
MsgBuf_RX2.Frame = 0x0;
MsgBuf_RX2.MsgID = 0x0;
MsgBuf_RX2.DataA = 0x0;
MsgBuf_RX2.DataB = 0x0;
CAN_SetACCF(ACCF_BYPASS);
while (1)
{
while (!(CAN2GSR & (1 << 0)) )
;
if (CAN2RxDone == TRUE)
{
tempbuf1 = MsgBuf_RX2.DataA; // Data A has 32 bits, of which only the
// first 16 bits are actual data
tempbuf2 = (tempbuf1 & 0x0000ffff); //??
current = tempbuf2;
if ((current/3) >= 25)
FIO2SET |= 0x00000001; ///??
}
CAN2RxDone = FALSE;
if (MsgBuf_RX2.Frame & (1 << 10)) //?
{
MsgBuf_RX2.Frame &= ~(1 << 10); //?
}
}
}
Keil provides some examples and programs for CAN development: http://www.keil.com/dd/vtr/4152/7837.htm
Here you can find CAN source for LPC2129: http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/
Here some examples: http://mbed.org/handbook/CAN
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am new in programming but I have a yacc/lex project and some difficulty in writing the error message in detail (line and type of error). Any help with a small example, please.
Add the following to your flex scanner definition, to cause the scanner to track line numbers:
%option yylineno
(See the flex manual.)
Then add the following declarations to your bison grammar:
%define parse.error verbose
%define parse.lac full
(See the bison manual chapters on error reporting and LAC (lookahead correction).
Finally, use a definition of yyerror which uses the line number information. At a minimum, something like:
void yyerror(const char* msg) {
fprintf(stderr, "At line %d: %s\n", yylineno, msg);
}
Ask bad questions get correct but uninformative answers
void yyerror(const char *s);
extern int line_num;
void yyerror(const char *s)
{
std::cerr << "PARSING ERROR: " << line_num << " " << s << std::endl;
exit(1);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am facing difficulties in Objective-C to Swift conversion. How to write below code in Swift?
int mib[2];
size_t length;
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
length = sizeof(int64_t);
sysctl(mib, 2, &physicalMemorySize, &length, NULL, 0);
mib[1] = HW_USERMEM;
length = sizeof(int64_t);
sysctl(mib, 2, &userMemorySize, &length, NULL, 0);
It is not too difficult if one knows two things:
The C int type is a 32-bit integer, this is Int32 in Swift,
not Int.
sizeof() from C is MemoryLayout<T>.stride in Swift.
Then we get:
var mib : [Int32] = [ CTL_HW, HW_MEMSIZE ]
var physicalMemorySize: Int64 = 0
var size = MemoryLayout<Int64>.stride
if sysctl(&mib, UInt32(mib.count), &physicalMemorySize, &size, nil, 0) == 0 {
print(physicalMemorySize)
} else {
print("sysctl failed")
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to implement a command line application in C/Objective C which will act as a calculator of more than two numbers.
E.g ./calc 5 + 4 * 6
= 29
I just need an idea or simple algorithm to start. I will appreciate any help on this.
The algorithm you want is the infix notation to postfix notation converter.
You can find some more info on it over here.
http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm.
EDIT: I am not sure if this will help, but here is an implementation in Java. I'm not familiar with Objective-C
// converts a infix string to postfix string
private void convertInfixToPostfix(){
// create an empty operand stack
operatorStack = new Stack<>();
Operator operator = null;
Operand operand = null;
for(int i = 0; i < expressionTokens.size(); i++){
String token = expressionTokens.get(i);
Element element = new Element(token);
if(element.isOperand(token)){ // check if element is operand
// add the element to the postfix string
operand = new Operand(element.getStringValue());
postFixString.add(operand);
}
else if(operatorStack.isEmpty()){
// push the token to the operator stack, its an operator
operator = new Operator(element.getStringValue());
operatorStack.push(operator);
}
else {
operator = new Operator(element.getStringValue());
while(!operatorStack.isEmpty() &&
(operatorStack.peek().getPrecedence()
<= operator.getPrecedence()))
postFixString.add(operatorStack.pop());
operatorStack.push(operator);
}
}
// add the rest of the operator stack to the postfix string
while(!operatorStack.isEmpty()){
Operator remainingOperator = operatorStack.pop();
postFixString.add(remainingOperator);
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I need to implement candlestick charts in windows metro app.Im not looking for any chart controls like visfire..ineed an open source code or a way ow to build it...Please help me...
OxyPlot is an open source, cross-platform .NET plotting library. It is available for WPF, Windows Store Apo, Silverlight & Windows Forms.
CodePlex Page : http://oxyplot.codeplex.com/
NuGet Package (You must have installed NuGet v2.1 or more) : http://nuget.org/List/Packages/OxyPlot.Metro
Sample App : http://apps.microsoft.com/webpdp/app/oxyplot-example-browser/95b37c05-f2b0-4186-b48e-01b6fcbeec5d
Here I am giving you demo of how to use candle stick series chart in Windwos store app
XAML
I have taken xmlns:oxy="using:OxyPlot.Metro" intag
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<oxy:Plot x:Name="Plot1" Background="White"/>
</Grid>
C#
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Plot1.Model = CandleStickSeries();
}
public PlotModel CandleStickSeries()
{
PlotModel plotModel = new PlotModel("Candle Stick Series", null)
{
LegendSymbolLength = 24.0
};
CandleStickSeries candleStickSeries = new CandleStickSeries("random values")
{
Color = OxyColors.Black
};
Random random = new Random();
double num = 100.0;
for (int i = 0; i < 16; i++)
{
num = num + random.NextDouble() + 0.1;
double num2 = num + 10.0 + random.NextDouble() * 10.0;
double num3 = num - (10.0 + random.NextDouble() * 10.0);
double open = num3 + random.NextDouble() * (num2 - num3);
double close = num3 + random.NextDouble() * (num2 - num3);
candleStickSeries.Items.Add(new HighLowItem((double)i, num2, num3, open, close));
}
plotModel.Series.Add(candleStickSeries);
plotModel.Axes.Add(new LinearAxis(AxisPosition.Left, double.NaN, double.NaN, null)
{
MaximumPadding = 0.3,
MinimumPadding = 0.3
});
return plotModel;
}
This is the only open source chart implementation for WindowsPhone I know: amCharts
HTH
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How can i get a process by know process name on mac os?
Just reformatted Haley's answer:
// Return YES if given name process in process list . Otherwise return NO
bool IsInBSDProcessList(char *name) {
assert( name != NULL);
kinfo_proc *result;
size_t count = 0;
result = (kinfo_proc *)malloc(sizeof(kinfo_proc));
if(GetBSDProcessList(&result,&count) == 0) {
for (int i = 0; i < count; i++) {
kinfo_proc *proc = NULL;
proc = &result[i];
if (strcmp(name, proc->kp_proc.p_comm) == 0) {
free(result);
return true;
}
}
}
free(result);
return false;
}
Your question is rather vague. Can you define what you mean by "get a process"?
One method (depending on your definition): launch the Activity Monitor app in Applications/Utilities, and look up the process name in the list.
Perhaps
ps -eaf
from a console