Search found 30 matches

by Fojtik
Thu 11. Nov 2021, 12:05
Forum: PCAN-Basic
Topic: Problem with function CAN_InitializeFD()
Replies: 3
Views: 3734

Re: Problem with function CAN_InitializeFD()

I am using PCAN-Basic under Windows.

The problem was related to allocation within Matlab and not from PEAK. Now the code works.

But still the documentation of "CAN_InitializeFD" mislead me to false expectation that a string pointer is used longer than during function call itself and immediate ...
by Fojtik
Mon 8. Nov 2021, 17:05
Forum: PCAN-Basic
Topic: Problem with function CAN_InitializeFD()
Replies: 3
Views: 3734

Problem with function CAN_InitializeFD()

I have big troubles with this function. There is undocumented behavior who deallocates the string passed.

If I do this:
TPCANStatus stsResult = CAN_InitializeFD(Channel, BitrateFD);
free(BitrateFD);

It causes program to crash.

When I toss away a pointer, it could cause leak. Who releases the ...
by Fojtik
Fri 31. Jan 2020, 13:30
Forum: Linux
Topic: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits
Replies: 5
Views: 5721

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Excuse me, another header collided with DWORD. Now seems everything OK.

Code: Select all

__u32 4 __u16 2 __u8 1
sizeof(unsigned char)=1
sizeof(unsigned short)=2
sizeof(unsigned int)=4
sizeof(unsigned long)=8

This thread could be erased not to confuse others.
by Fojtik
Fri 31. Jan 2020, 13:04
Forum: Linux
Topic: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits
Replies: 5
Views: 5721

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

It seems that there is something more weird:
printf("__u32 %ld __u16 %ld __u8 %ld\n", sizeof(__u32), sizeof(__u16), sizeof(__u8));

printf("sizeof(unsigned char)=%lu\n", sizeof(unsigned char));
printf("sizeof(unsigned short)=%lu\n", sizeof(unsigned short));
printf("sizeof(unsigned int)=%lu\n ...
by Fojtik
Fri 31. Jan 2020, 12:54
Forum: Linux
Topic: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits
Replies: 5
Views: 5721

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

The header pcan.c is from 2010.

C standard 2011 define these types:
https://pubs.opengroup.org/onlinepubs/0 ... int.h.html
https://en.cppreference.com/w/cpp/types/integer

Code: Select all

The following types are required:
int8_t
int16_t
int32_t
uint8_t
uint16_t
uint32_t
by Fojtik
Fri 31. Jan 2020, 12:25
Forum: Linux
Topic: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits
Replies: 5
Views: 5721

Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

I have found a critical issue.

typedef __signed__ int __s32;
typedef unsigned int __u32;
this __u32 has size 64 bit and not 32 bit.

pcan.h forces:
#else
#define DWORD __u32
#define WORD __u16
#define BYTE __u8
#endif
DWORD to 64 bit int and it corrupts my code. Is there any way how to get out ...
by Fojtik
Wed 8. Jan 2020, 19:07
Forum: Linux
Topic: Phantom messages read - possible bug in PCAN Linux
Replies: 2
Views: 3296

Re: Phantom messages read - possible bug in PCAN Linux

This "unwanted" message could be caused by service message (they start without any request), but even when so, the service mesasage does not signalise select command, so the receiver dependent on "select" hangs.

/** Internal working thread that listens for new messages. */
void *CanPeak ...
by Fojtik
Wed 8. Jan 2020, 14:36
Forum: Linux
Topic: Phantom messages read - possible bug in PCAN Linux
Replies: 2
Views: 3296

Phantom messages read - possible bug in PCAN Linux

After disconnecting and connecting CAN cable I have read bunch of phantom CAN messages, see attached file for details. First number is time mark in [ms].

8182873 Message P-CAN received Id=1, Len=4 0 0 0 0
8182873 Message P-CAN received Id=2, Len=4 0 0 0 4
8182873 Message P-CAN received Id=3, Len=4 ...
by Fojtik
Mon 21. Oct 2019, 18:11
Forum: Linux
Topic: Is there any mutex inside PcanBASIC in Linux?
Replies: 4
Views: 14728

Re: Is there any mutex inside PcanBASIC in Linux?

Thank you very much for hint. It seems to work as expected.

There is only one flaw inside your demo (fix included in this fragment):
struct timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
int err = select(fd+1, &fds, NULL, NULL, &timeout);
if(err!=0) // Timeout ocurred -> err==0 ...
by Fojtik
Fri 18. Oct 2019, 18:57
Forum: Linux
Topic: Would you like to bave P-CANBasic Debian deb package?
Replies: 1
Views: 9222

Would you like to bave P-CANBasic Debian deb package?

I have packed your library to .deb package.

I cannot post to this forum .deb extension file :( . I can send it, if somebody has interest. It is much more convenient to do regular installation process than "make install".