Please send the complete output when the IOC starts and it does the communication at initialization.
You need to send writeReadController once, and then readController. That should read the second ";" without sending the command again.
this->writeReadController();
this->readController();
From: lynn <lynn0703 at yeah.net>
Sent: Monday, May 29, 2023 5:50 AM
To: Mark Rivers <rivers at cars.uchicago.edu>
Cc: tech-talk <tech-talk at aps.anl.gov>
Subject: Re:Re: some motor driver 3 questions
Hi Mark,
Thank you so much for you help.
I modified startup script, using (';') as the terminator.
Then added the initialiation command in construct MCB4BController::MCB4BController like bellow.
it worked except some problems.
MCB4BController::MCB4BController(....) : asynMotorController()
{
sprintf(this->outString_,"MO=1");
this->writeReadController();
// this->writeReadController();
}
The problem:
i send "mo=1;", device would sendback "mo=1;" ,then sendback ";".
There is many place like these, this motor. not because the outputEos.
My C was poor. I tried to add line "this->writeReadController();", it became write twice command and read twice.
How should i readout twice in one command?
Regards,
Lynn
--
|
lynn
|
邮箱:lynn0703 at yeah.net
|
在 2023-05-26 21:27:03,"Mark Rivers" <rivers at cars.uchicago.edu> 写道:
1) why command "ID;" did not work? Both "PX;" and "ID;" were in MCB4BAxis::poll function. Obviously, "PX;" was send ,"ID;" didn't.
You see this in the output:
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
So the low-level read returned 1, which is asynTimeout. This is interpreted as an error
condition. It expects 0, asynSuccess.
The code is here:
sprintf(pC_->outString_,
"PX;");
comStatus = pC_->writeReadController();
if (comStatus) goto skip;
So if comStatus is not 0 it jumps to "skip" and does not send the ID command.
I don't see any \r or \n in the response from the device. Does it use a semicolon (';') as the terminator? If so you need to set that with asynOctetSetInputEos in your startup script.
2) how to achieve it, if I want to send some initialization command ?
You can send an initialization command in the axis or controller constructor code.
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?
I think you need to set the terminator to ;. Then you need to do 2 reads to read the response. The first will read px, the second will read the value.
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;");
That code is not correct. You need to change it to this:
if (relative) {
sprintf(pC_->outString_, "PR=%d;", NINT(position));
comStatus
= pC_->writeReadController();
sprintf(pC_->outString_,
"BG;");
comStatus
= pC_->writeReadController();
} else {
sprintf(pC_->outString_,
"PA=%d;", NINT(position));
comStatus
= pC_->writeReadController();
sprintf(pC_->outString_,
"BG;");
comStatus
= pC_->writeReadController();
Mark
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of lynn via Tech-talk <tech-talk at aps.anl.gov>
Sent: Wednesday, May 24, 2023 7:11 AM
To: tech-talk <tech-talk at aps.anl.gov>
Subject: some motor driver 3 questions
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
|
|