Click here to Skip to main content
15,891,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,
I am struggling to access SDS application layer using Softing CAN Layer2 CANL2_send_data() function. The CAN interface was successfully initialized and ready for writing and reading.

int CANL2_send_data(CAN_HANDLE can, unsigned long Ident, int Xtd, int DataLength, byte *pData);


Function Parameters:
- can: Channel handle
- Ident: Identifier
- Xtd: Identifier length (0: 11 bits, 1: 29 bits)
- DataLength: Number of data bytes to be transmitted

SDS header info:
Logical Address: 64
Service Type: 100 (write)
Identifier: 0x204
Service Parameter: Attribute 206
Data: (data format?)
//////////////////////////////////////////////////////////////////////////

Problems:
1. SDS data frame showing missing first 2 bytes (72 65) from “reboot\r\n” (72 65 62 6f 6f 74 0d 0a). The output is captured in CAN/SDS monitor on other PC with CANusb located at the same bus.
2. DLC is reduced into 6 (SDS max data bytes) but how send data that is more 6 bytes?
3. SDS parameters such as Service Specifiers, EOID, Service Parameters did not find their slots in above CAN send data function.
4. FRC returned 0, the data did reach the microcontroller (confirmed with CAN RX LED indicator) but it does not response accordingly.


Thanks in advanced
mraaf

What I have tried:

unsigned char* pData = "reboot\r\n";
int nLength = strlen((const char*)pData); // get length of the string
static unsigned int nID = 0x204;
int frc; // function return code

frc = CANL2_send_data(
m_hCAN[1],        // can1 handle
nID,              // Identifier
0,                // 11 bits (standard identifier)
nLength,          // data length
pData);           // pointer to the address field of the data


Quote:
SDS Data Output:
Tx/Rx: Rx | Direction: [IN] | Address: 64 | APDU: Write | DLC: 6 | Data: 62 6f 6f 74 d a | frc: 0

///////////////////////////////////////////////////////////////////////

Function return codes:
0 Function successful
-1 Function not successful
-11 Unknown error
-104 Timeout firmware communication
-1000 Invalid channel handle
Posted
Updated 11-May-17 6:00am
v2

I don't know the used CAN library and have not used CAN so far.

But it seems that you have mixed up your nCount and nLength values. The DataLength parameter of the function CANL2_send_data() function must be probably the length of the data string.

So I would exchange the initialisation of the length variables:
// Wrong:
//int nCount = strlen((const char*)pData); // get length of the string
//static int nLength = (int) 8 - nID;
// Should be:
int nLength = strlen((const char*)pData); // get length of the string
static int nCount = (int) 8 - nID;

There seems also to be no reason for sending the same command string multiple times (especially if reboot is doing what the names assumes).
 
Share this answer
 
Comments
mraaf 9-May-17 5:43am    
I have fixed the mixed up and remove the loop. However SDS data frame monitor showing missing first 2 bytes while CAN data frame monitor showing all bytes were read.
Jochen Arndt 9-May-17 6:02am    
I'm sorry but as already noted I have not used CAN or SDS so far.

I can only guess that you have to create data packets according to the SDS protocol specification and send that via CAN.

That is:
Send the SDS header followed by the payload data. Actually you are just sending a string and I assume that the SDS monitor is treating the first two characters of that string as header and does not display them as data therefore.
mraaf 9-May-17 7:03am    
Thank you Jochen, it's make sense now: the missing data must be my missing fields for Embedded Object ID and Service Parameters.
Got it worked:

unsigned char pData[5];
Ident = 0x204 // SDS logical address 64, service type 4	
pData[0] = 0; // EOID 0
pData[1] = 0xCE; // Attribute 206 for tx
pData[2] = *pXMT; // ASCII char
nLength = 3;
 
frc = CANL2_send_data(m_hCAN[1], Ident, 0, nLength, (unsigned char*)pData);


Then call it 8 times (once per character) for command "reboot\r\n"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900