Hi all,
Nowadayas i was writing elmo motor driver.
i modified from MCB4BDriver.cpp (model 3 example).
I found it was in a loop from AsynTrace message, after starting st.cmd.
********************* AsynTrace out, Begin*************************
2023/05/24 18:30:14.347 wrote 3 to 192.168.1.5:5001 udp, return asynSuccess.
2023/05/24 18:30:14.347 asynOctetSyncIO wrote:
PX;
2023/05/24 18:30:14.347 192.168.1.5:5001 udp read.
2023/05/24 18:30:14.350 192.168.1.5:5001 udp (from 192.168.1.5:5001) read 11
PX;-106202;
2023/05/24 18:30:14.350 serial1 read 11 bytes eom=0
PX;-106202;
2023/05/24 18:30:14.350 192.168.1.5:5001 udp read.
2023/05/24 18:30:16.352 serial1 read from low-level driver returned 1
2023/05/24 18:30:16.352 serial1 queueUnlockPort
2023/05/24 18:30:16.352 serial1 asynManager::queueUnlockPort waiting for event
2023/05/24 18:30:16.352 serial1 queueUnlockPort unlock mutex 0x7f605c000e90 complete.
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort locking port
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort taking mutex 0x7f605c000e90
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort queueing request
2023/05/24 18:30:16.452 serial1 addr -1 queueRequest priority 0 not lockHolder
2023/05/24 18:30:16.452 serial1 schedule queueRequest timeout in 2.000000 seconds
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort waiting for event
2023/05/24 18:30:16.452 asynManager::portThread port=serial1 callback
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPortCallback signaling begin event
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort got event from callback
2023/05/24 18:30:16.452 serial1 flush
2023/05/24 18:30:16.452 192.168.1.5:5001 udp flush
2023/05/24 18:30:16.452 192.168.1.5:5001 udp write.
2023/05/24 18:30:16.452 192.168.1.5:5001 udp write 3
PX;
2023/05/24 18:30:16.452 wrote 3 to 192.168.1.5:5001 udp, return asynSuccess.
Another loop begin.
************* AsynTrace out, End ******************
Since loop was about "px;", I checked driver.cpp, found that "PX" only came out in MCB4BAxis::poll function.
Here is the code of MCB4BAxis::Poll.
********************* MCB4BAxis::poll Begin *************************
asynStatus MCB4BAxis::poll(bool *moving)
{
int done;
int driveOn;
int limit;
double position;
asynStatus comStatus;
sprintf(pC_->outString_, "PX;");
comStatus = pC_->writeReadController();
if (comStatus) goto skip;
position = atof(&pC_->inString_[3]);
setDoubleParam(pC_->motorPosition_, position);
// Read the moving status of this motor
sprintf(pC_->outString_, "ID;");
comStatus = pC_->writeReadController();
if (comStatus) goto skip;
done = (float(pC_->inString_[3]) > 0.009) ? 1:0;
setIntegerParam(pC_->motorStatusDone_, done);
*moving = done ? false:true;
********************* MCB4BAxis::poll End *************************
Could someone help me with these questions:
1) why command "ID;" did not work? Both "PX;" and "ID;" were in MCB4BAxis::poll function. Obviously, "PX;" was send ,"ID;" didn't.
2) how to achieve it, if I want to send some initialization command ?
3)
When I send "px;". Device would not send "PX=15926;" back.
It would send "px;" first,then "15268;". I means, they are not send together.
Does I need to change some in my code?
4)
Device required command "PR=1000;", then send "BG;". it would not work if send together.
How to write these code ?
if (relative) {
sprintf(pC_->outString_, "PR=%d;", NINT(position));
sprintf(pC_->outString_, "BG;");
// I added a line here. Does it ok?
} else {
sprintf(pC_->outString_, "PA=%d;", NINT(position));
sprintf(pC_->outString_, "BG;");
Any suggestion was appreciate.
Thanks.
Regards,
Lynn
--
|
lynn
|
邮箱:lynn0703 at yeah.net
|