Could not format log-string - windows-xp

while recieving snmptrap on linux system...every thing working fine,but in windows server & XP I am getting Could not format log-string.Anyone please help me to solve this problem.
I am using Net-SNMP-5.6.1.1 for windows server.
Thanks in Advance

This is because of supplied snprintf() is used instead of sprintf() as it does limit checks
for string length. or because of Void debugmsg_hex(const char *token, const u_char * thedata, size_t len) which can accept no longer than LOGLENGTH==1024.
Resolve:
verify snmp_logging.c and remove checks.
CODE
what is complete error message. I need the printed code.

Related

`do_sys_open` vs `__x86_sys_open` when attaching kprobe

I have tried running opensnoop.py but using
fnname_open='do_sys_open'
(which I have seen in other scripts) instead of
fnname_open = b.get_syscall_prefix().decode() + 'open'
# = '__x86_sys_open' on Ubuntu 18.04
but the script then stops printing file names. What is causing the difference?
When using attach_kprobe(event=fn) is fn a system call or an event?
Do you get list of possible syscall from /proc/kallsyms as described here?
A BPF program attached to __x86_sys_open won't have the same result if you attach it to do_sys_open instead because those two functions don't have the same prototype:
long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode);
long sys_open(const char __user *filename, int flags, umode_t mode);
So the filename argument, for example, won't be stored in the same register depending on which function you trace. You will need to edit the BPF program as well to fix this.

Eclipse Nsight CDT plugin pressing F3 to Open Declaration goes to the wrong line

Nsight Eclipse Edition
Version: 5.5.0
CDT version: 8.1.2.nvidia-qualifier
Quick reference upon mouse over pops up the wrong declaration. Usually it's a function, which is located at the same header file, as the one I'm looking for, but it has no relation to it so far. For example:
For cudaMemcpy() it shows me this function from "cuda_runtime_api.h":
extern __host__ cudaError_t CUDARTAPI cudaPointerGetAttributes(struct cudaPointerAttributes *attributes, void *ptr);
For cudaMalloc() it gives me the description of:
extern __host__ cudaError_t CUDARTAPI cudaMemcpy2DToArray(struct cudaArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind);
Why is indexing behaving this way? I'm getting tired of it after a couple of days working, but still couldn't find any obvious solution for this issue.
I will log this issue in our issue tracker. Sorry for the inconvenience. There is no workaround available.
Note that for performance reasons, Nsight does not index those files on your system. Instead, it comes prepackaged with compiled index files - apparently some headers might be different from the versions Nsight index was built from.

Linux DD passing data to serial port ttyS0

Hi i want to pass a data from my char device driver to serial port ttyS0..
I have created a simple char driver module which reads and write and it's my first tym doing it.. i am using debian guest os...
e.g.
echo "hello" > /dev/mydev
now when /dev/mydev receives the data it will then alter the string into something like "hello too" which is passed to my serial port /dev/ttyS0..
how can i alter the string?.. is it possible to use if statement inside mydev?
e.g
if(string=="hello"){
alterstringTO: hello to;
pass "hello to" /dev/ttyS0;
like echoing in terminal..
echo "hello to" > /dev/ttyS0
}
Is that possible?... or is there any other way doing it?
Here some of the code..
ssize_t dev_read(struct file *filp, char *buf, size_t clen, loff_t *f_pos){
short cnt =0;
while(clen && (msg[Pos]!=0))
{
put_user(msg[Pos],buf++);
cnt++;
clen--;
Pos++;
}
return cnt;
}
ssize_t dev_write(struct file *filp, const char *buf, size_t clen, loff_t *f_pos){
short dec = clen-1;
short cnt=0;
memset(msg,0,50);
Pos=0;
while(clen>0)
{
msg[cnt++] = buf[dec--];
clen--;
}
return cnt;
}
Thanks in advance..
Just a comment on writing to the serial port:
Remember the Linux foundations, everything is a file in Linux. To write to the device driver from a program you need to open the file for writing and then you can fprintf whatever data you want. You can do that from user space as well (the recommended way)
Refer to the following man pages:
man fopen
man fread/fwrite
man fprintf
man fclose
I'm not exactly sure what you are trying to achieve here, as the question and the intent seems unclear to me. I'll provide some guidance, but recommend that you edit your question and make it more readable.
Your snippet to compare strings is not correct. You can learn more about how to compare strings in C in here.
Altering a string in C is a basic operation that you learn when you start working with strings. This should help you getting started.
As final remark, please note that programming for the kernel requires extra care. A small mistake may lead to a crash and loss of data. If you really must, then the book Linux Device Drivers 3rd Edition is freely available and can help you further.

Printing Receipt on Star Micronics TSP 650 Printer through iPad

I am using Star iOS SDK to print receipts (like a restaurant bill) but am facing problems implementing column settings and cell spacing for proper alignment. I have checked out the documentation but have not found something useful.
The line code manual has some signals/commands which I am unable to understand. Can anyone help me out with that?
The commands referenced in the Line Mode manual need to be converted into bytes and then sent to the printer. The StarIO iOS SDK package you downloaded has a manual called "README_StarIO_POSPrinter_iOS_SDK.pdf". (http://www.starmicronics.com/absolutefm/absolutefm/afmviewfaq.aspx?faqid=175) Did you check out pages 9-15? The StarIO framework is explained here.
Specific to your question about sending commands, page 13 shows you how to write to the port using a byte array, but make sure you add StarIO.framework and open the communication port first.
From the manual:
//Set a byte array to send to the printer
//command = { A, B, C, D, Feed 3mm, Full Cut}
unsigned char command = {0x41, 0x42, 0x43, 0x44, 0x1B, 0x7A, 0x00, 0x1B, 0x64, 0x02};
Uint bytesWritten = 0;
#Try
{
While(bytesWritten < (sizeof command))
{
bytesWritten += [port writePort: command : bytesWritten : sizeof command - bytesWritten];
}
}
#Catch(PortException)
{
//There was an error writing to the port
}
Also described is how to close ports (make sure you close every opened port) and getting printer status.
Let me know if this helps.
I talked to SDK developers of start micronics, as I was facing the same problem using TSP100 model. Here is the reply from one of their tech guy.
"Unlike most of our other models the TSP100 series is a bit unique in that it is raster only meaning that it does not have the text formatting commands that our other printers do (ie, the printer just prints whatever receipt image you send it). Any formatting would be done in your application however you would like to do it before creating the image to send to the printer"
So this is clear that you have to maintain the column width, formatting, alignment etc everything by yourself.

I'm sending a command to a serial COM port in C# and not getting data back, but when I use Putty I get data - what am I doing wrong?

I have a C# application, which I'm writing to try automate data extraction from a serial device. As the title of my question says, I have tried the exact same commands in Putty and I get data back. Could somebody please tell me what I have missed out, so that I can get the same data out with my C# application please?
Basically, I need to COM6, a speed/baud of 57600, and send the command without quotes "UH". I should be presented with a few lines of text data, which appears to only work on Putty.
As a quick test, I threw this together:
private void SerialPort serialPort = new SerialPort();
private void getHistory_Click(object sender, EventArgs e)
{
serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
serialPort.PortName = "COM6";
serialPort.BaudRate = 57600;
serialPort.Open();
if (serialPort.IsOpen())
{
serialPort.Write("UH");
}
}
private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string result = serialPort.ReadExisting();
Invoke(new MethodInvoker(delegate{ textbox1.AppendText(result); }));
}
The DataReceived event does get fired, but it only returns back the "UH" I sent up, no further data. Any help with this problem would be highly appreciated!
Justin
Well, without further detail of the device in question, it is hard to say for sure, but two things spring to mind:
Firstly, what comms protocol does the device require? You have set up the baud rate, but have no mention of data bits, parity, or stop bits. I think the .NET serial port class defaults to 8,N,1. If your device is the same then you should be fine. If it is not, then it won't work.
Secondly, does the device require any kind of termination to the data to define a complete packet? Commonly this can be the data sent is appended with a carriage return and a line feed (0x0D and 0x0A), or perhaps is has a prefix of STX (0x02) and a suffix of ETX (0x03).
Any message that the device responds with is likely to be in the same format too.
I don't know how Putty works, but check the setup and see if it is appending anything to the message you type, and the protocol. Hyperterminal does this too, so you could test it with this also.